mmackh / Hacker-News-for-iOS

Hacker News client for iPad and iPhone [DEPRECATED]
588 stars 169 forks source link

App crashes while moving to new article very fast. #8

Closed satheeshwaran closed 11 years ago

satheeshwaran commented 11 years ago

When pressing the down button continuously in the reader view the app crashes giving this exception

2013-07-18 00:44:40.684 Hacker News[3654:c07] * Terminating app due to uncaught exception 'NSRangeException', reason: '-[__NSCFString replaceOccurrencesOfString:withString:options:range:]: Range or index out of bounds' * First throw call stack: (0x1938012 0x1700e7e 0x1937deb 0x1936857 0x11709ab 0x2029b 0x75e1 0x1efae 0x7581 0x12ca6 0x1b9b53f 0x1bad014 0x1b9d7d5 0x18deaf5 0x18ddf44 0x18dde1b 0x20b17e3 0x20b1668 0x64865c 0x2e80 0x2de5) libc++abi.dylib: terminate called throwing an exception

The source of this exception happens in these lines of code:

[self.webView loadHTMLString:string baseURL:nil];
__weak MAMReaderViewController *weakSelf = self;
[_story loadClearReadLoadBody:^(NSString *resultBody)
 {
         NSString *clearReadDocument = [string stringByReplacingOccurrencesOfString:@"Loading...  " withString:resultBody options:0 range:NSMakeRange(0, _string.length)];
         [clearReadDocument writeToFile:storyLink atomically:NO encoding:NSUTF8StringEncoding error:nil];
         [weakSelf.webView loadHTMLString:clearReadDocument baseURL:nil];

}];

Please look into it, you guys have done a great job building this. I am looking forward to use some of the features in my app.

mmackh commented 11 years ago

Fixed in 89e08e1ef3d983a065ee2aa5970daf795d0a9698

satheeshwaran commented 11 years ago

Superfast fix! I will test it and update you.

satheeshwaran commented 11 years ago

Its working fine now, thanks.