iPhone - Multithreading in Tableview - feasible approach? - iphone

I have been tracking a nasty bug recently of which I knew it was occurring due to my multithreaded approach (I add the crashreport at the end).
In my App I load a UITableView and fill it with data I store using Coredata. This data in turn I retrieve from a webservice, thus it might take some time, depending on my connection.
Anyway, I have managed to track it down a little and I know the issue is because an array is empty though I thought it shouldn't be. Then, when
numberOfRowsInSection:(NSInteger)section
is called the program crashes - but only sometimes!!!
I was wondering how to debug this properly and my approach was to call
reloadData
on the tableView after the view finishes loading. But appearantly
- (void)viewDidLoad
but of course this didn't help. Is the correct way here to create another thread and have it check repeatadly whether the data is ready and prepared? Any suggestions/opinions?
2011-01-19 21:50:49.605 myApp[2017:307] *** Terminating app due to uncaught exception
'NSRangeException', reason: '*** -[NSMutableArray objectAtIndex:]: index 0 beyond bounds for empty array'
*** Call stack at first throw:
(
0 CoreFoundation 0x314d0987 __exceptionPreprocess + 114
1 libobjc.A.dylib 0x319a149d objc_exception_throw + 24
2 CoreFoundation 0x31462795 -[__NSArrayM objectAtIndex:] + 184
3 myApp 0x000092f7 -[MyTableViewController tableView:numberOfRowsInSection:] + 106
4 UIKit 0x33902bcf -[UISectionRowData refreshWithSection:tableView:tableViewRowData:] + 1338
5 UIKit 0x33903529 -[UITableViewRowData(UITableViewRowDataPrivate) _ensureSectionOffsetIsValidForSection:] + 120
6 UIKit 0x33902645 -[UITableViewRowData numberOfRows] + 96
7 UIKit 0x3390207b -[UITableView noteNumberOfRowsChanged] + 82
8 UIKit 0x33901bff -[UITableView reloadData] + 582
9 UIKit 0x33904a0b -[UITableView _reloadDataIfNeeded] + 50
10 UIKit 0x33904e63 -[UITableView layoutSubviews] + 18
11 UIKit 0x338b10cf -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 26
12 CoreFoundation 0x3146ebbf -[NSObject(NSObject) performSelector:withObject:] + 22
13 QuartzCore 0x30a6c685 -[CALayer layoutSublayers] + 120
14 QuartzCore 0x30a6c43d CALayerLayoutIfNeeded + 184
15 QuartzCore 0x30a6656d _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 212
16 QuartzCore 0x30a66383 _ZN2CA11Transaction6commitEv + 190
17 QuartzCore 0x30a70e4f _ZN2CA11Transaction5flushEv + 46
18 QuartzCore 0x30a6db75 +[CATransaction flush] + 24
19 UIKit 0x338e803f -[UIApplication _reportAppLaunchFinished] + 30
20 UIKit 0x338d6317 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 462
21 UIKit 0x338a248b -[UIApplication handleEvent:withNewEvent:] + 1114
22 UIKit 0x338a1ec9 -[UIApplication sendEvent:] + 44
23 UIKit 0x338a1907 _UIApplicationHandleEvent + 5090
24 GraphicsServices 0x35d66f03 PurpleEventCallback + 666
25 CoreFoundation 0x314656ff __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 26
26 CoreFoundation 0x314656c3 __CFRunLoopDoSource1 + 166
27 CoreFoundation 0x31457f7d __CFRunLoopRun + 520
28 CoreFoundation 0x31457c87 CFRunLoopRunSpecific + 230
29 CoreFoundation 0x31457b8f CFRunLoopRunInMode + 58
30 UIKit 0x338d5309 -[UIApplication _run] + 380
31 UIKit 0x338d2e93 UIApplicationMain + 670
32 myApp 0x000029bf main + 70
33 myApp 0x00002974 start + 40
)
terminate called after throwing an instance of 'NSException'
numberOfRows looks like:
- (NSInteger)tableView:(UITableView *)aTableView numberOfRowsInSection:(NSInteger)section {
// Return the number of rows in the section.
NSLog(#"number of rows in section");
if (section == mySection) {
return [[articleArrays objectAtIndex:section] count];
} else {
return 0;
}
}

From what you describe here your process that performs the download, or more precisely an event callback should be the only place calling reload data. calling it after adding new data to the table dataSet.
returning a 0 in numberOfRowsInSection does not cause a crash but if you are trying to get a nested array when the count is 0, this will crash. Post your numberOfRowsInSection method for us to gawk at.
EDIT:
Sounds/Looks like background thread is mutating the array while its trying to do an object count.
user210504 is right in saying that synchronising the array is likely stop this.
Typically you would sync writes and therefore preventing numberOfRowsInSection from counting if your background thread is mutating it. eg:
-(void)downloadFinished{
NSMutableArray * array = [[NSArray alloc] init];//t
id * obj;//obj is your row data object.
#synchronized(ar)
{
[array addObject:obj];//ar is your dataSet
}
[array release];
}

One thing that you can do is to encapsulate accesses to the Mutable Array in #synchronized block. This way you will be sure that you are not accessing the datastructure half way through. And then I also agree with what Luke just mentioned.

Related

"Drink Mixer" Example Head First iPhone & iPad Development

i'm kinda new to Objective-C so i have been learning with the Head First iPhone & iPad Development book. In this book, at the Chapter 4-5 you suppose to design an app for a bartender, that basically is a table view of a list of drinks with the details list (it suppose to have the ingredients and directions for the drink selected). The data comes from two property lists, one has a list of strings with the names of the drinks, and the other is a Dictionary that has the name, directions and ingredients of the drinks.
I have followed the tutorial and the app crashes, re-checked it and still crashes. I'm using an Xcode Version of 4.0.1 and MAC OS X 10.6.8.
Here is the exception, i hope that you guys can check out what happens at this simple application.
2012-07-19 21:43:39.757 DrinkMixer[846:207] -[NSCFString objectForKey:]: unrecognized selector sent to instance 0x4b31220
2012-07-19 21:43:39.761 DrinkMixer[846:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSCFString objectForKey:]: unrecognized selector sent to instance 0x4b31220'
*** Call stack at first throw:
(
0 CoreFoundation 0x00dc25a9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x00f16313 objc_exception_throw + 44
2 CoreFoundation 0x00dc40bb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
3 CoreFoundation 0x00d33966 ___forwarding___ + 966
4 CoreFoundation 0x00d33522 _CF_forwarding_prep_0 + 50
5 DrinkMixer 0x00002495 -[RootViewController tableView:cellForRowAtIndexPath:] + 325
6 UIKit 0x00089b98 -[UITableView(UITableViewInternal) _createPreparedCellForGlobalRow:withIndexPath:] + 634
7 UIKit 0x0007f4cc -[UITableView(UITableViewInternal) _createPreparedCellForGlobalRow:] + 75
8 UIKit 0x000948cc -[UITableView(_UITableViewPrivate) _updateVisibleCellsNow:] + 1561
9 UIKit 0x0008c90c -[UITableView layoutSubviews] + 242
10 QuartzCore 0x016aca5a -[CALayer layoutSublayers] + 181
11 QuartzCore 0x016aeddc CALayerLayoutIfNeeded + 220
12 QuartzCore 0x016540b4 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 310
13 QuartzCore 0x01655294 _ZN2CA11Transaction6commitEv + 292
14 UIKit 0x000169c9 -[UIApplication _reportAppLaunchFinished] + 39
15 UIKit 0x00016e83 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 690
16 UIKit 0x00021617 -[UIApplication handleEvent:withNewEvent:] + 1533
17 UIKit 0x00019abf -[UIApplication sendEvent:] + 71
18 UIKit 0x0001ef2e _UIApplicationHandleEvent + 7576
19 GraphicsServices 0x00ffb992 PurpleEventCallback + 1550
20 CoreFoundation 0x00da3944 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
21 CoreFoundation 0x00d03cf7 __CFRunLoopDoSource1 + 215
22 CoreFoundation 0x00d00f83 __CFRunLoopRun + 979
23 CoreFoundation 0x00d00840 CFRunLoopRunSpecific + 208
24 CoreFoundation 0x00d00761 CFRunLoopRunInMode + 97
25 UIKit 0x000167d2 -[UIApplication _run] + 623
26 UIKit 0x00022c93 UIApplicationMain + 1160
27 DrinkMixer 0x00001c89 main + 121
28 DrinkMixer 0x00001c05 start + 53
)
terminate called after throwing an instance of 'NSException'
sharedlibrary apply-load-rules all
(gdb)
And here is exactly when the app crashes, at the objectForKey:#"name"
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = #"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
cell.textLabel.text = [[self.drinks objectAtIndex:indexPath.row] objectForKey:#"name"];
return cell;
}
the clue in the first line of the error is that you have initialized the contents of self.drinks at the index that corresponds to indexPath.row to be an NSString. when that objectAtIndex: is retrieved, it is then passed the message objectForKey: as though it is an NSArray.
look at the code where you've initialized self.drinks and make certain you've made it an appropriate array containing appropriate contents. in your case, it would be an array of NSDictionary* for objectForKey: to work).
Debug your code and check drinks is an array of NSDictonary.

Objective-C NSMutableArray:removeObjectsInRange

I have a NSMutableArray called rawData of size 198792. Each index contains an NSObject called DataSet. The interface for a DataSet is as follows:
#interface DataSet : NSObject {
NSNumber *rightFoot;
NSNumber *leftFoot;
}
I am trying to trim down the rawData using the following line of code:
[rawData removeObjectsInRange:NSMakeRange(0, StartTime*freq-1)];
where StartTime*freq-1 = 11799.
I am getting an error during runtime:
* Terminating app due to uncaught exception 'NSRangeException', reason: '* -[NSMutableArray objectAtIndex:]: index 198791 beyond bounds [0 .. 186992]'
Thank you for any help!
EDIT: stack trace
2012-02-16 17:59:31.671 fwd_analysis[8154:207] *** Terminating app due to uncaught
exception 'NSRangeException', reason: '*** -[NSMutableArray objectAtIndex:]: index
198791 beyond bounds [0 .. 186992]'
*** Call stack at first throw:
(
0 CoreFoundation 0x00dc25a9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x00f16313 objc_exception_throw + 44
2 CoreFoundation 0x00db80a5 -[__NSArrayM objectAtIndex:] + 261
3 fwd_analysis 0x00002a99 -[fwd_analysisViewController startButtonPressed:] + 252
4 UIKit 0x002b24fd -[UIApplication sendAction:to:from:forEvent:] + 119
5 UIKit 0x00342799 -[UIControl sendAction:to:forEvent:] + 67
6 UIKit 0x00344c2b -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 527
7 UIKit 0x003437d8 -[UIControl touchesEnded:withEvent:] + 458
8 UIKit 0x002d6ded -[UIWindow _sendTouchesForEvent:] + 567
9 UIKit 0x002b7c37 -[UIApplication sendEvent:] + 447
10 UIKit 0x002bcf2e _UIApplicationHandleEvent + 7576
11 GraphicsServices 0x0171a992 PurpleEventCallback + 1550
12 CoreFoundation 0x00da3944 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
13 CoreFoundation 0x00d03cf7 __CFRunLoopDoSource1 + 215
14 CoreFoundation 0x00d00f83 __CFRunLoopRun + 979
15 CoreFoundation 0x00d00840 CFRunLoopRunSpecific + 208
16 CoreFoundation 0x00d00761 CFRunLoopRunInMode + 97
17 GraphicsServices 0x017191c4 GSEventRunModal + 217
18 GraphicsServices 0x01719289 GSEventRun + 115
19 UIKit 0x002c0c93 UIApplicationMain + 1160
20 fwd_analysis 0x00002758 main + 102
21 fwd_analysis 0x000026e9 start + 53
)
terminate called after throwing an instance of 'NSException'
Current language: auto; currently objective-c
Program received signal: “SIGABRT”.
Your array can't be the size you think it is.
Look at the error message: index beyond bounds [0 .. 186992]. Therefore the size of your array is actually 186993.
I would also recommend you log the value of StartTime*freq-1 at runtime, and compare it with the length of your array.
Also, something that could cause issues here is that it's a mutable array, and you're removing stuff from it, so the length will change at runtime. This is why I recommend logging both the length and range at the point where the code breaks.
So, something like this:
NSLog(#"Length: %i",[rawData length]);
NSLog(#"Range: %i",StartTime*freq-1);
[rawData removeObjectsInRange:NSMakeRange(0, StartTime*freq-1)];
Update: how to add objects to another array instead of deleting from the current one.
You need to use this method to get an array which contains objects in a certain range:
- (NSArray *)subarrayWithRange:(NSRange)range
You can then add these objects into another array, for example:
// before you did this:
[rawData removeObjectsInRange:NSMakeRange(0, StartTime*freq-1)];
// to create a filtered array do:
NSArray *filtered = [rawData subarrayWithRange:NSMakeRange(0, StartTime*freq-1)];

iphone updating tableview after searching issue

When I search on TableView through TextDidChange which calls handleSearchTerm subroutine, it perfectly works. However, I removed TextDidChange and use SearchButtonClicked to update tableView (use same subroutine),it doesn't update TableView properly and crash when scroll(out of bound index in cellForRowAtIndex) even though datasource has been changed in subroutine. Any idea?
[78515:207] *** Terminating app due to uncaught exception 'NSRangeException', reason: '-[__NSCFArray objectAtIndex:]: index (8) beyond bounds (8)'
*** Call stack at first throw:
(
0 CoreFoundation 0x00db8be9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x00f0d5c2 objc_exception_throw + 47
2 CoreFoundation 0x00d71628 +[NSException raise:format:arguments:] + 136
3 CoreFoundation 0x00d7159a +[NSException raise:format:] + 58
4 CoreFoundation 0x00dae8c9 _NSArrayRaiseBoundException + 121
5 CoreFoundation 0x00db0027 -[__NSCFArray objectAtIndex:] + 87
6 DrinkGuide_v1.0 0x00005d6c -[AllDrinkTableViewController tableView:cellForRowAtIndexPath:] + 371
7 UIKit 0x003357fa -[UITableView(UITableViewInternal) _createPreparedCellForGlobalRow:withIndexPath:] + 634
8 UIKit 0x0032b77f -[UITableView(UITableViewInternal) _createPreparedCellForGlobalRow:] + 75
9 UIKit 0x00340450 -[UITableView(_UITableViewPrivate) _updateVisibleCellsNow:] + 1561
10 UIKit 0x00338538 -[UITableView layoutSubviews] + 242
11 QuartzCore 0x01c76451 -[CALayer layoutSublayers] + 181
12 QuartzCore 0x01c7617c CALayerLayoutIfNeeded + 220
13 QuartzCore 0x01c6f37c _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 310
14 QuartzCore 0x01c6f0d0 _ZN2CA11Transaction6commitEv + 292
15 QuartzCore 0x01c9f7d5 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 99
16 CoreFoundation 0x00d99fbb __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 27
17 CoreFoundation 0x00d2f0e7 __CFRunLoopDoObservers + 295
18 CoreFoundation 0x00cf7bd7 __CFRunLoopRun + 1575
19 CoreFoundation 0x00cf7240 CFRunLoopRunSpecific + 208
20 CoreFoundation 0x00cf7161 CFRunLoopRunInMode + 97
21 GraphicsServices 0x016ed268 GSEventRunModal + 217
22 GraphicsServices 0x016ed32d GSEventRun + 115
23 UIKit 0x002d042e UIApplicationMain + 1160
24 DrinkGuide_v1.0 0x0000298c main + 102
25 DrinkGuide_v1.0 0x0000291d start + 53
)
terminate called after throwing an instance of 'NSException'
I think crash is caused by cellForRowAtIndexPath, can you please post code for following methods :
cellForRowAtIndexPath
SearchButtonClicked
yourSubroutine you are calling
also mention your array or collection from which you are loading your table.
Thanks,
as per your crash log it seems you are retuning wrong no of cells in you noOfcellsInsection method. You are getting array out of bounds error.When you are doing search make a flag true and according to that flag return no of rows for the table view using your filtered array's count.

unrecognized selector sent to instance. Method being called for random objects

Ok, so this has me completely stumped just like the guy here with the exact problem.
I have a UITableView with some rows in a view controller which supports autorotation and sometimes, if i rotate the phone, i get "EXC_BAD_ACCESS" and sometimes i get SIGABRT with a stack trace like:
2010-11-19 16:51:05.634 [2306:307] -[CABasicAnimation numberOfSectionsInTableView:]: unrecognized selector sent to instance 0x58207d0
2010-11-19 16:51:05.688 [2306:307] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[CABasicAnimation numberOfSectionsInTableView:]: unrecognized selector sent to instance 0x58207d0'
*** Call stack at first throw:
(
0 CoreFoundation 0x344aaed3 __exceptionPreprocess + 114
1 libobjc.A.dylib 0x33975811 objc_exception_throw + 24
2 CoreFoundation 0x344ac683 -[NSObject(NSObject) doesNotRecognizeSelector:] + 102
3 CoreFoundation 0x344541d9 ___forwarding___ + 508
4 CoreFoundation 0x34453f90 _CF_forwarding_prep_0 + 48
5 UIKit 0x31b20717 -[UITableViewRowData(UITableViewRowDataPrivate) _updateNumSections] + 66
6 UIKit 0x31b20677 -[UITableViewRowData invalidateAllSections] + 50
7 UIKit 0x31b2048d -[UITableView(_UITableViewPrivate) _updateRowData] + 64
8 UIKit 0x31b22941 -[UITableView(_UITableViewPrivate) _ensureRowDataIsLoaded] + 24
9 UIKit 0x31b22909 -[UITableView numberOfSections] + 16
10 UIKit 0x31bd114f -[UISearchDisplayController _updateNoSearchResultsMessageVisiblity] + 54
11 UIKit 0x31cfbef7 -[UISearchDisplayController windowWillAnimateRotation:] + 478
12 Foundation 0x3325d6b3 _nsnote_callback + 142
13 CoreFoundation 0x34431713 __CFXNotificationPost_old + 402
14 CoreFoundation 0x344313b3 _CFXNotificationPostNotification + 118
15 Foundation 0x3324cdb7 -[NSNotificationCenter postNotificationName:object:userInfo:] + 70
16 UIKit 0x31b5dbb7 -[UIWindow _setRotatableClient:toOrientation:duration:force:] + 3114
17 UIKit 0x31b64013 -[UIWindow _setRotatableViewOrientation:duration:force:] + 50
18 UIKit 0x31b39a0f -[UIWindow _updateToInterfaceOrientation:duration:force:] + 74
19 UIKit 0x31b39be9 -[UIWindow _updateInterfaceOrientationFromDeviceOrientation:] + 112
20 UIKit 0x31b39b15 -[UIWindow _handleDeviceOrientationChange:] + 88
21 Foundation 0x3325d6b3 _nsnote_callback + 142
22 CoreFoundation 0x34431713 __CFXNotificationPost_old + 402
23 CoreFoundation 0x344313b3 _CFXNotificationPostNotification + 118
24 Foundation 0x3324cdb7 -[NSNotificationCenter postNotificationName:object:userInfo:] + 70
25 UIKit 0x31b0d0ed -[UIDevice setOrientation:animated:] + 144
26 UIKit 0x31b2a51b -[UIApplication handleEvent:withNewEvent:] + 2738
27 UIKit 0x31b29901 -[UIApplication sendEvent:] + 44
28 UIKit 0x31b29337 _UIApplicationHandleEvent + 5110
29 GraphicsServices 0x3026c04b PurpleEventCallback + 666
30 CoreFoundation 0x3443fce3 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 26
31 CoreFoundation 0x3443fca7 __CFRunLoopDoSource1 + 166
32 CoreFoundation 0x3443256d __CFRunLoopRun + 520
33 CoreFoundation 0x34432277 CFRunLoopRunSpecific + 230
34 CoreFoundation 0x3443217f CFRunLoopRunInMode + 58
35 GraphicsServices 0x3026b5f3 GSEventRunModal + 114
36 GraphicsServices 0x3026b69f GSEventRun + 62
37 UIKit 0x31ad0123 -[UIApplication _run] + 402
38 UIKit 0x31ace12f UIApplicationMain + 670
39 App 0x0000285f main + 70
40 App 0x00002814 start + 40
)
terminate called after throwing an instance of 'NSException'
Program received signal: “SIGABRT”.
In this case it is CABasicAnimation on which numberOfSectionsInTableView is being called but sometimes there are class names like NSMachPort which i have never heard of. Also, the method being called numberOfSectionsInTableView remains the same with the class names changing to always give a doesNotRecognizeSelector exception.
Also this problem only happens when i try to rotate the device. Whenever i get a stack trace like above, there are all system functions which makes it difficult to debug.
Really need some expert advice on this. Please read the forum mentioned above to be clear about the issue.
Whoa! I thought i knew NSZombies enough but i was wrong!
I enabled NSZombies which led me to:
*** -[ContactsViewController numberOfSectionsInTableView:]: message sent to deallocated instance 0x88dafa0
Doing "po 0x88dafa0" wont work because that object's memory was already freed.
Some more Googling led me to this where the author describes how to find freed/deallocated objects. We just have to set MallocStackLoggingNoCompact to 1 in the Variables to be set in the environment along with NSZombieEnabled.
The output i got with the info malloc-history 0xf270740 command had a line:
-[VoicePlayController actionSheet:clickedButtonAtIndex:] at /Users/Documents/Xcode Projects/Classes/VoicePlayController.m:454
The code on that line is:
contactsViewController = [[ContactsViewController alloc] initWithNibName:#"ContactsViewController" bundle:nil];
I moved the [contactsViewController release]; line to dealloc method instead of immediately after [self.navigationController presentModalViewController:contactsViewController animated:YES]; and the problem is gone!
Start with enabling NSZombies. What it sounds like is you are over-releasing an object.

iOS Application Terminates After Exception Thrown in UITableViewDataSource Method

Having meticulously followed the examples and instructions in the Table View Programming Guide for iOS about the proper order in which UITableView delegate and data source methods are called, I thought I had a good idea of how to implement the “handshake” shown in Figure 7-1 and the list that follows, but apparently not.
Here's the code I'm using…
- (void) tableView: (UITableView *) tableView commitEditingStyle: (UITableViewCellEditingStyle) editingStyle forRowAtIndexPath: (NSIndexPath *) indexPath {
NSLog(#"Removing %# row %d.", [dataModel objectAtIndex: indexPath.row], indexPath.row);
[tableView deleteRowsAtIndexPaths: [NSArray arrayWithObjects: indexPath, nil] withRowAnimation: UITableViewRowAnimationFade];
[dataModel removeObjectAtIndex: indexPath.row];
}
tableView is the UITableView
dataModel is an NSArray instance that holds the objects represented by the UITableViewCells from the tableView.
…and the error I'm getting…
2010-08-27 21:53:17.971 SportWatch[1299:307] *** Assertion failure in -[UITableView _endCellAnimationsWithContext:], /SourceCache/UIKit/UIKit-1262.58/UITableView.m:920
2010-08-27 21:53:17.992 SportWatch[1299:307] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid update: invalid number of rows in section 0. The number of rows contained in an existing section after the update (4) must be equal to the number of rows contained in that section before the update (4), plus or minus the number of rows inserted or deleted from that section (0 inserted, 1 deleted).'
*** Call stack at first throw:
(
0 CoreFoundation 0x35411ed3 __exceptionPreprocess + 114
1 libobjc.A.dylib 0x311f0811 objc_exception_throw + 24
2 CoreFoundation 0x35411d15 +[NSException raise:format:arguments:] + 68
3 Foundation 0x332b932f -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 62
4 UIKit 0x338dcda1 -[UITableView(_UITableViewPrivate) _endCellAnimationsWithContext:] + 4524
5 UIKit 0x338d586d -[UITableView _updateRowsAtIndexPaths:updateAction:withRowAnimation:] + 204
6 UIKit 0x338d5775 -[UITableView deleteRowsAtIndexPaths:withRowAnimation:] + 20
7 SportWatch 0x000060e7 -[MainViewController tableView:commitEditingStyle:forRowAtIndexPath:] + 670
8 UIKit 0x338d3c3f -[UITableView(UITableViewInternal) animateDeletionOfRowWithCell:] + 58
9 UIKit 0x33984071 -[UITableViewCell(UITableViewCellInternal) deleteConfirmationControlWasClicked:] + 28
10 CoreFoundation 0x353b9719 -[NSObject(NSObject) performSelector:withObject:withObject:] + 24
11 UIKit 0x33831d59 -[UIApplication sendAction:to:from:forEvent:] + 84
12 UIKit 0x33831cf9 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 32
13 UIKit 0x33831ccb -[UIControl sendAction:to:forEvent:] + 38
14 UIKit 0x33831a1d -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 356
15 UIKit 0x3383206b -[UIControl touchesEnded:withEvent:] + 342
16 UIKit 0x338309f5 -[UIWindow _sendTouchesForEvent:] + 368
17 UIKit 0x3383036f -[UIWindow sendEvent:] + 262
18 UIKit 0x3382ae13 -[UIApplication sendEvent:] + 298
19 UIKit 0x3382a74b _UIApplicationHandleEvent + 5110
20 GraphicsServices 0x3171a04b PurpleEventCallback + 666
21 CoreFoundation 0x353a6ce3 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 26
22 CoreFoundation 0x353a6ca7 __CFRunLoopDoSource1 + 166
23 CoreFoundation 0x3539956d __CFRunLoopRun + 520
24 CoreFoundation 0x35399277 CFRunLoopRunSpecific + 230
25 CoreFoundation 0x3539917f CFRunLoopRunInMode + 58
26 GraphicsServices 0x317195f3 GSEventRunModal + 114
27 GraphicsServices 0x3171969f GSEventRun + 62
28 UIKit 0x337d148b -[UIApplication _run] + 402
29 UIKit 0x337cf69f UIApplicationMain + 670
30 SportWatch 0x00002b23 main + 70
31 SportWatch 0x00002ad8 start + 40
)
terminate called after throwing an instance of 'NSException'
Program received signal: “SIGABRT”.
kill
Current language: auto; currently objective-c
quit
remove the object from the data set before deleting the row.