I've got some inconsistencies with the app UIEvents (Scrolling, Reloading) and backgroundthread work. Occasional "NSRangeException" is kinda annoying, though not life threatning, nevertheless, for the sake of good code,
Here is where the conflict is showing up. I occasionally keep getting "Index beyond bounds" error.
This specially occurs when:
I tap a button, that fills the tableView. I scroll down to the last row. While the tableView scrolls, I tap another button that reloads the tableView with Lesser data(rows) and thats where the error comes out! Sometimes it works, sometimes i get the following:
Here is the IBAction:
1- Sqlite querying via NSOperation.
2- After getting data in an array the following method is called in MainThread in AppDelegate
Particularly "updateVisibleCells" gives me a clue to the problem, but im not sure what exactly it is.
Im not sure what do I do here. This error is eating my brain! hellppp
Here is where the conflict is showing up. I occasionally keep getting "Index beyond bounds" error.
This specially occurs when:
I tap a button, that fills the tableView. I scroll down to the last row. While the tableView scrolls, I tap another button that reloads the tableView with Lesser data(rows) and thats where the error comes out! Sometimes it works, sometimes i get the following:
Here is the IBAction:
1- Sqlite querying via NSOperation.
2- After getting data in an array the following method is called in MainThread in AppDelegate
Code:
[self.mainController performSelectorOnMainThread:@selector(cacheArray:) withObject:dataArray waitUntilDone:NO];
Code:
- (void) cacheArray:(NSArray *)CurentArray{
self.currMainArray = CurentArray;
if(CurrentArray) [tableView reloadData];
}
Code:
Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[NSMutableArray objectAtIndex:]: index 33 beyond bounds [0 .. 14]
Code:
(
0 CoreFoundation 0x36440303 __exceptionPreprocess + 114
1 libobjc.A.dylib 0x3523d4c4 objc_exception_throw + 40
2 CoreFoundation 0x363c1751 -[__NSArrayM objectAtIndex:] + 184
3 MyAppN 0x0000af2b -[MainViewController tableView:cellForRowAtIndexPath:] + 156
4 UIKit 0x32405250 -[UITableView(UITableViewInternal) _createPreparedCellForGlobalRow:withIndexPath:] + 652
5 UIKit 0x32404eb4 -[UITableView(UITableViewInternal) _createPreparedCellForGlobalRow:] + 52
6 UIKit 0x323cb488 -[UITableView(_UITableViewPrivate) _updateVisibleCellsNow:] + 1308
7 UIKit 0x323c8e48 -[UITableView layoutSubviews] + 208
8 UIKit 0x32370ab8 -[UIView(CALayerDelegate) _layoutSublayersOfLayer:] + 40
9 CoreFoundation 0x363c85c1 -[NSObject(NSObject) performSelector:withObject:] + 24
10 QuartzCore 0x30c8c624 -[CALayer layoutSublayers] + 184
11 QuartzCore 0x30c8c2ac CALayerLayoutIfNeeded + 200
12 QuartzCore 0x30c8bbb8 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 264
13 QuartzCore 0x30c8b7e0 _ZN2CA11Transaction6commitEv + 284
14 QuartzCore 0x30c939e0 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 88
15 CoreFoundation 0x3641424b __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 18
16 CoreFoundation 0x36415da5 __CFRunLoopDoObservers + 500
17 CoreFoundation 0x364172fd __CFRunLoopRun + 940
18 CoreFoundation 0x363be0c3 CFRunLoopRunSpecific + 226
19 CoreFoundation 0x363bdfd1 CFRunLoopRunInMode + 60
20 GraphicsServices 0x33c4cf90 GSEventRunModal + 196
21 UIKit 0x32363b48 -[UIApplication _run] + 572
22 UIKit 0x32361fc0 UIApplicationMain + 972
23 MyAppN 0x00002e39 main + 80
24 MyAppN 0x00002db0 start + 52
)
Particularly "updateVisibleCells" gives me a clue to the problem, but im not sure what exactly it is.
Code:
6 UIKit 0x323cb488 -[UITableView(_UITableViewPrivate) _updateVisibleCellsNow:] + 1308
Im not sure what do I do here. This error is eating my brain! hellppp