i have problem when i try delete or add object a the list
errror:
2014-09-04 10:59:03.815 DeleteListTest[2781:60b] *** Assertion failure in -[UITableView _endCellAnimationsWithContext:], /SourceCache/UIKit_Sim/UIKit-2935.137/UITableView.m:1368
2014-09-04 10:59:03.856 DeleteListTest[2781:60b] *** 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 (9) must be equal to the number of rows contained in that section before the update (10), plus or minus the number of rows inserted or deleted from that section (0 inserted, 0 deleted) and plus or minus the number of rows moved into or out of that section (0 moved in, 0 moved out).'
*** First throw call stack:
(
0 CoreFoundation 0x01b581e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x018d78e5 objc_exception_throw + 44
2 CoreFoundation 0x01b58048 +[NSException raise:format:arguments:] + 136
3 Foundation 0x014b74de -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 116
4 UIKit 0x0066ff63 -[UITableView _endCellAnimationsWithContext:] + 13402
5 UIKit 0x0067fcea -[UITableView endUpdatesWithContext:] + 51
6 UIKit 0x0067fd18 -[UITableView endUpdates] + 41
7 DeleteListTest 0x00002ece -[MasterViewController leaveEditMode] + 270
8 DeleteListTest 0x0000301a -[MasterViewController tableView:commitEditingStyle:forRowAtIndexPath:] + 202
9 UIKit 0x006916a3 -[UITableView animateDeletionOfRowWithCell:] + 107
10 UIKit 0x0081a595 -[UITableViewCell _swipeDeleteButtonPushed] + 70
11 libobjc.A.dylib 0x018e9880 -[NSObject performSelector:withObject:withObject:] + 77
12 UIKit 0x005993b9 -[UIApplication sendAction:to:from:forEvent:] + 108
13 UIKit 0x00599345 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 61
14 UIKit 0x0069abd1 -[UIControl sendAction:to:forEvent:] + 66
15 UIKit 0x0069afc6 -[UIControl _sendActionsForEvents:withEvent:] + 577
16 UIKit 0x0069a243 -[UIControl touchesEnded:withEvent:] + 641
17 UIKit 0x0092f2e3 _UIGestureRecognizerUpdate + 7166
18 UIKit 0x005d8a5a -[UIWindow _sendGesturesForEvent:] + 1291
19 UIKit 0x005d9971 -[UIWindow sendEvent:] + 1021
20 UIKit 0x005ab5f2 -[UIApplication sendEvent:] + 242
21 UIKit 0x00595353 _UIApplicationHandleEventQueue + 11455
22 CoreFoundation 0x01ae177f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
23 CoreFoundation 0x01ae110b __CFRunLoopDoSources0 + 235
24 CoreFoundation 0x01afe1ae __CFRunLoopRun + 910
25 CoreFoundation 0x01afd9d3 CFRunLoopRunSpecific + 467
26 CoreFoundation 0x01afd7eb CFRunLoopRunInMode + 123
27 GraphicsServices 0x03a0a5ee GSEventRunModal + 192
28 GraphicsServices 0x03a0a42b GSEventRun + 104
29 UIKit 0x00597f9b UIApplicationMain + 1225
30 DeleteListTest 0x00004a4d main + 141
31 libdyld.dylib 0x0219f701 start + 1
32 ??? 0x00000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
this is the delete method
if(editingStyle == UITableViewCellEditingStyleDelete){
[tableTitles removeObjectAtIndex:[indexPath row]];
[self leaveEditMode];
[[self tableView] reloadData];
someone can help me ? thx u :)
I believe you are missing the call to:
[self.tableView deleteRowsAtIndexPaths:indexPath
withRowAnimation:UITableViewRowAnimationFade];
and you don't need the reloadData call:
if (editingStyle == UITableViewCellEditingStyleDelete) {
[tableTitles removeObjectAtIndex:[indexPath row]];
[self.tableView deleteRowsAtIndexPaths:#[indexPath]
withRowAnimation:UITableViewRowAnimationFade];
[self leaveEditMode];
(this will also look better as it will give visual feedback to the user; unlike reloadData).
Related
My Application is getting crashed while scrolling UIWebview - I have used ILPDFKit for implementing interactive PDF - Editable Forms.App is getting crashed only if i am adding more than 126 Objects.
Here is code I am using (from ILPDFKit)
for (PDFWidgetAnnotationView *element in widgetAnnotationViews)
{
element.alpha = 0;
element.parentView = self;
[_pdfView.scrollView addSubview:element];
[_pdfView.scrollView bringSubviewToFront:element];
if ([element isKindOfClass:[PDFFormButtonField class]])
{
[(PDFFormButtonField*)element setButtonSuperview];
}
}
I have also raise Issue here
I have added some customview's in my webview.scrollview , so while scrolling webview my App is getting crashed. i have checked for all possible solutions i found on google/stackoverflow.
none of the delegate method of scrollview / webview called before this crash , as soon as i tried to scroll and app is getting crashed.
below is crash report.
*** Terminating app due to uncaught exception 'NSGenericException', reason: '*** Collection <__NSArrayM: 0x6000024535f0> was mutated while being enumerated.'
*** First throw call stack:
(
0 CoreFoundation 0x00000001045dd34b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x0000000103f5f21e objc_exception_throw + 48
2 CoreFoundation 0x0000000104645f1c __NSFastEnumerationMutationHandler + 124
3 CoreFoundation 0x0000000104582638 -[NSArray makeObjectsPerformSelector:] + 424
4 UIKit 0x00000001020d8f4f -[UIScrollView(UIScrollViewInternal) _notifyDidScroll] + 163
5 UIKit 0x00000001020c3919 -[UIScrollView setContentOffset:] + 478
6 UIKit 0x00000001020c8351 -[UIScrollView _updatePanGesture] + 2346
7 UIKit 0x0000000102531289 -[UIGestureRecognizerTarget _sendActionWithGestureRecognizer:] + 57
8 UIKit 0x0000000102539028 _UIGestureRecognizerSendTargetActions + 109
9 UIKit 0x0000000102536af7 _UIGestureRecognizerSendActions + 227
10 UIKit 0x0000000102535d83 -[UIGestureRecognizer _updateGestureWithEvent:buttonEvent:] + 891
11 UIKit 0x0000000102521e56 _UIGestureEnvironmentUpdate + 1395
12 UIKit 0x000000010252189b -[UIGestureEnvironment _deliverEvent:toGestureRecognizers:usingBlock:] + 521
13 UIKit 0x0000000102520a7e -[UIGestureEnvironment _updateGesturesForEvent:window:] + 286
14 UIKit 0x000000010205f7ad -[UIWindow sendEvent:] + 3989
15 UIKit 0x000000010200ca33 -[UIApplication sendEvent:] + 371
16 UIKit 0x00000001027feb6d __dispatchPreprocessedEventFromEventQueue + 3248
17 UIKit 0x00000001027f7817 __handleEventQueue + 4879
18 CoreFoundation 0x0000000104582311 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
19 CoreFoundation 0x000000010456759c __CFRunLoopDoSources0 + 556
20 CoreFoundation 0x0000000104566a86 __CFRunLoopRun + 918
21 CoreFoundation 0x0000000104566494 CFRunLoopRunSpecific + 420
22 GraphicsServices 0x0000000107910a6f GSEventRunModal + 161
23 UIKit 0x0000000101feef34 UIApplicationMain + 159
24 HyundaiCapital 0x000000010132a67f main + 111
25 libdyld.dylib 0x000000010610268d start + 1
26 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Edit
1.How many subviews at most i can add into delegate of scrollview at a time?
2.I am only getting this crash if i am adding subviews more than 126?
Solution
Updating ILPDFKit worked for me.
The application crashes at replaceobjectatindex .
The clickedbuttonpath.row returns nil value . Need help .
- (void)textFieldDidEndEditing:(UITextField *)textField
{
if (textField.text.length>0)
{
UITableViewCell *clickedCell = (UITableViewCell *)[[textField superview] superview];
NSIndexPath *clickedButtonPath = [addSizesTableView_ indexPathForCell:clickedCell];
if (textField.tag==6)
{
[textDic setObject:textField.text forKey:clickedButtonPath];
[orderArr replaceObjectAtIndex:clickedButtonPath.row withObject:textField.text];
This is the crash log which am getting .
'NSInvalidArgumentException', reason: '* setObjectForKey: key cannot be nil'
* First throw call stack:
(
0 CoreFoundation 0x0000000106d1ef35 exceptionPreprocess + 165
1 libobjc.A.dylib 0x00000001062acbb7 objc_exception_throw + 45
2 CoreFoundation 0x0000000106c25998 -[__NSDictionaryM setObject:forKey:] + 968
3 BookMyStock 0x0000000103559ac0 -[AddSizesOfColors textFieldDidEndEditing:] + 368
4 UIKit 0x0000000105289549 -[UITextField _resignFirstResponder] + 382
5 UIKit 0x0000000104ccc4f5 -[UIResponder resignFirstResponder] + 236
6 UIKit 0x00000001052892d4 -[UITextField resignFirstResponder] + 114
7 UIKit 0x0000000105295953 -[UIView(UITextField) endEditing:] + 173
8 BookMyStock 0x0000000103557c2d -[AddSizesOfColors addTFTotheView] + 285
9 UIKit 0x0000000104b568be -[UIApplication sendAction:to:from:forEvent:] + 75
10 UIKit 0x0000000104c5d410 -[UIControl _sendActionsForEvents:withEvent:] + 467
11 UIKit 0x0000000104c5c7df -[UIControl touchesEnded:withEvent:] + 522
12 UIKit 0x0000000104b9c308 -[UIWindow _sendTouchesForEvent:] + 735
13 UIKit 0x0000000104b9cc33 -[UIWindow sendEvent:] + 683
14 UIKit 0x0000000104b699b1 -[UIApplication sendEvent:] + 246
15 UIKit 0x0000000104b76a7d _UIApplicationHandleEventFromQueueEvent + 17370
16 UIKit 0x0000000104b52103 _UIApplicationHandleEventQueue + 1961
17 CoreFoundation 0x0000000106c54551 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 17
18 CoreFoundation 0x0000000106c4a41d __CFRunLoopDoSources0 + 269
19 CoreFoundation 0x0000000106c49a54 __CFRunLoopRun + 868
20 CoreFoundation 0x0000000106c49486 CFRunLoopRunSpecific + 470
21 GraphicsServices 0x0000000108bdc9f0 GSEventRunModal + 161
22 UIKit 0x0000000104b55420 UIApplicationMain + 1282
23 BookMyStock 0x0000000103492913 main + 115
24 libdyld.dylib 0x0000000107c7e145 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
[[textField superview] superview] returns nil, incase of iOS 8, whereas in iOS 7 it returns some value. As suggested in below link, don't rely on view hierarchy.
You can check this link Getting UITableViewCell from its superview iOS 7 issue
You can try below like structure
CGPoint subviewPosition = [textField convertPoint:CGPointZero toView:self.tableView];
NSIndexPath* clickedButtonPath = [addSizesTableView_ indexPathForRowAtPoint:subviewPosition];
I have a UIPageViewController which holds two screens.
self.pageController = [[UIPageViewController alloc] initWithTransitionStyle:UIPageViewControllerTransitionStyleScroll navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal options:nil];
And one of the screen contains tableview on iphone /Collection view on ipad.On some user event we are setting the contentOfset to move the tableview a bit up
[table setContentOffset:cell.frame.origin animated:YES];
Then user navigates to next screen using UIPageviewcontroller
Above usecase causes crash on the app with the following logs
2014-11-14 09:04:46.783 tibbr[12329:79833] *** Assertion failure in -[_UIQueuingScrollView _setWrappedViewAtIndex:withView:], /SourceCache/UIKit_Sim/UIKit-3318.16.14/_UIQueuingScrollView.m:338
2014-11-14 09:04:46.786 tibbr[12329:79833] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Unexpected subviews'
*** First throw call stack:
(
0 CoreFoundation 0x0000000113512f35 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x0000000111be7bb7 objc_exception_throw + 45
2 CoreFoundation 0x0000000113512d9a +[NSException raise:format:arguments:] + 106
3 Foundation 0x00000001115c15df -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 195
4 UIKit 0x00000001108715e0 -[_UIQueuingScrollView _setWrappedViewAtIndex:withView:] + 215
5 UIKit 0x0000000110871b0a -[_UIQueuingScrollView _replaceViews:updatingContents:adjustContentInsets:animated:] + 672
6 UIKit 0x0000000110873e57 -[_UIQueuingScrollView setView:direction:animated:completion:] + 524
7 UIKit 0x00000001107d5e16 -[UIPageViewController _setViewControllers:withScrollInDirection:animated:completion:] + 483
8 UIKit 0x00000001107d5f78 -[UIPageViewController setViewControllers:direction:animated:completion:] + 157
12 UIKit 0x000000011024e8be -[UIApplication sendAction:to:from:forEvent:] + 75
13 UIKit 0x0000000110355410 -[UIControl _sendActionsForEvents:withEvent:] + 467
14 UIKit 0x00000001103cf9ea -[UISegmentedControl _setSelectedSegmentIndex:notify:animate:] + 570
15 UIKit 0x00000001103d1a0f -[UISegmentedControl touchesEnded:withEvent:] + 143
16 UIKit 0x00000001105fb540 _UIGestureRecognizerUpdate + 9487
17 UIKit 0x0000000110293ff6 -[UIWindow _sendGesturesForEvent:] + 1041
18 UIKit 0x0000000110294c23 -[UIWindow sendEvent:] + 667
19 UIKit 0x00000001102619b1 -[UIApplication sendEvent:] + 246
20 UIKit 0x000000011026ea7d _UIApplicationHandleEventFromQueueEvent + 17370
21 UIKit 0x000000011024a103 _UIApplicationHandleEventQueue + 1961
22 CoreFoundation 0x0000000113448551 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
23 CoreFoundation 0x000000011343e41d __CFRunLoopDoSources0 + 269
24 CoreFoundation 0x000000011343da54 __CFRunLoopRun + 868
25 CoreFoundation 0x000000011343d486 CFRunLoopRunSpecific + 470
26 GraphicsServices 0x0000000113e859f0 GSEventRunModal + 161
27 UIKit 0x000000011024d420 UIApplicationMain + 1282
28 tibbr 0x000000010cb942d1 tibbr + 58065
29 libdyld.dylib 0x0000000112660145 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Kindly do suggest me what could be root cause of this issue
Im doing an iOS app(actually just copying code) from this tutorial http://hubpages.com/hub/Tutorial-on-Creating-an-IOS-5-SQLite-Database-Application-IOS-5-SQLite
and I can't run my app. Build succeds and then I get signal SIGABRT in my XCode.
2014-08-28 09:04:40.105 Whine2[526:60b] Problem with prepare statement
2014-08-28 09:04:40.109 Whine2[526:60b] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 0 beyond bounds for empty array'
*** First throw call stack:
(
0 CoreFoundation 0x018d81e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x016578e5 objc_exception_throw + 44
2 CoreFoundation 0x018793f6 -[__NSArrayM objectAtIndex:] + 246
3 Whine2 0x000029bd -[kcbViewController viewDidLoad] + 269
4 UIKit 0x0043633d -[UIViewController loadViewIfRequired] + 696
5 UIKit 0x004365d9 -[UIViewController view] + 35
6 UIKit 0x00356267 -[UIWindow addRootViewControllerViewIfPossible] + 66
7 UIKit 0x003565ef -[UIWindow _setHidden:forced:] + 312
8 UIKit 0x0035686b -[UIWindow _orderFrontWithoutMakingKey] + 49
9 UIKit 0x003613c8 -[UIWindow makeKeyAndVisible] + 65
10 UIKit 0x00311bc0 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 2097
11 UIKit 0x00316667 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 824
12 UIKit 0x0032af92 -[UIApplication handleEvent:withNewEvent:] + 3517
13 UIKit 0x0032b555 -[UIApplication sendEvent:] + 85
14 UIKit 0x00318250 _UIApplicationHandleEvent + 683
15 GraphicsServices 0x038cdf02 _PurpleEventCallback + 776
16 GraphicsServices 0x038cda0d PurpleEventCallback + 46
17 CoreFoundation 0x01853ca5 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53
18 CoreFoundation 0x018539db __CFRunLoopDoSource1 + 523
19 CoreFoundation 0x0187e68c __CFRunLoopRun + 2156
20 CoreFoundation 0x0187d9d3 CFRunLoopRunSpecific + 467
21 CoreFoundation 0x0187d7eb CFRunLoopRunInMode + 123
22 UIKit 0x00315d9c -[UIApplication _run] + 840
23 UIKit 0x00317f9b UIApplicationMain + 1225
24 Whine2 0x0000282d main + 141
25 libdyld.dylib 0x01e21701 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
I understand there is some problem with array, right?
As your error message and code in the link says, there is one array named wines in viewDidLoad of kcbViewController and it is empty. aJust log the array wines before accessing it . If you need to check whether an array is empty, you can check if self.wines.count is 0.
My developing iOS application is sometimes terminated after the method addSubview: is called in the application delegate (but I'm not sure removeFromSuperview: also involved):
[self.tabBarController.view removeFromSuperview];
[self.window addSubview:navigationController.view];
What that showed in the log is:
*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[NSMutableArray objectAtIndex:]: index 0 beyond bounds for empty array'
*** Call stack at first throw:
(
0 CoreFoundation 0x019b75a9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x01c41313 objc_exception_throw + 44
2 CoreFoundation 0x019ad0a5 -[__NSArrayM objectAtIndex:] + 261
3 <app_name> 0x000186dd -[TableViewController tableView:numberOfRowsInSection:] + 205
4 UIKit 0x00a742b7 -[UISectionRowData refreshWithSection:tableView:tableViewRowData:] + 1834
5 UIKit 0x00a71eb1 -[UITableViewRowData numberOfRowsInSection:] + 110
6 UIKit 0x00b60807 -[UISearchDisplayController _updateNoSearchResultsMessageVisiblity] + 115
7 Foundation 0x01029669 _nsnote_callback + 145
8 CoreFoundation 0x0198f9f9 __CFXNotificationPost_old + 745
9 CoreFoundation 0x0190e93a _CFXNotificationPostNotification + 186
10 Foundation 0x0101f20e -[NSNotificationCenter postNotificationName:object:userInfo:] + 134
11 UIKit 0x008df649 -[UIWindow _setRotatableClient:toOrientation:updateStatusBar:duration:force:] + 4581
12 UIKit 0x008d9254 -[UIWindow _setRotatableViewOrientation:duration:force:] + 89
13 UIKit 0x008db38f -[UIWindow setAutorotates:forceUpdateInterfaceOrientation:] + 794
14 UIKit 0x008d9081 -[UIWindow setDelegate:] + 252
15 UIKit 0x00964dee -[UIViewController _tryBecomeRootViewControllerInWindow:] + 106
16 UIKit 0x00975340 -[UINavigationController viewDidMoveToWindow:shouldAppearOrDisappear:] + 72
17 UIKit 0x008f0e4b -[UIView(Internal) _didMoveFromWindow:toWindow:] + 918
18 UIKit 0x008efa60 -[UIView(Hierarchy) _postMovedFromSuperview:] + 166
19 UIKit 0x008e8750 -[UIView(Internal) _addSubview:positioned:relativeTo:] + 1080
20 UIKit 0x008e6aa3 -[UIView(Hierarchy) addSubview:] + 57
21 <app_name> 0x00004971 -[AppDelegate requestFinished:] + 993
22 <app_name> 0x0003e65b -[ASIHTTPRequest reportFinished] + 171
23 Foundation 0x0103e94e __NSThreadPerformPerform + 251
24 CoreFoundation 0x019988ff __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
25 CoreFoundation 0x018f688b __CFRunLoopDoSources0 + 571
26 CoreFoundation 0x018f5d86 __CFRunLoopRun + 470
27 CoreFoundation 0x018f5840 CFRunLoopRunSpecific + 208
28 CoreFoundation 0x018f5761 CFRunLoopRunInMode + 97
29 GraphicsServices 0x01db11c4 GSEventRunModal + 217
30 GraphicsServices 0x01db1289 GSEventRun + 115
31 UIKit 0x008c5c93 UIApplicationMain + 1160
32 <app_name> 0x00002a30 main + 192
33 <app_name> 0x00002255 start + 53
)
terminate called throwing an exception
How can I find out the reason why the app is terminated by this log and solve it? Thank you.
Note: Edit 1 and Edit 2 were removed.
Edit 3: This implemented code of tableView:numberOfRowsInSection: method works for me:
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
if (tableView == self.searchDisplayController.searchResultsTableView)
{
if (filteredSectionListOfAddressBook && filteredSectionListOfAddressBook.count)
{
return [[filteredSectionListOfAddressBook objectAtIndex:section] count];
}
else
{
return 0;
}
}
else if (tableView == self.tableView)
{
if (sectionListOfAddressBook && sectionListOfAddressBook.count)
{
return [[sectionListOfAddressBook objectAtIndex:section] count];
}
else
{
return 0;
}
}
return 0;
}
In your stack trace - there is a tableview - you need to ensure that there is data to populate the table. Thats where this error is coming from
*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[NSMutableArray objectAtIndex:]: index 0 beyond bounds for empty array
You could for the moment ensure there is no data by making sure that
tableView:numberOfRowsInSection: returns 0;
Have you implemented the TableViews delegate methods?
Read about it here About Table Views in iOS-Based Applications
here UITableViewDataSource Protocol Reference
and here UITableViewDelegate Protocol Reference
I just ran into a problem like this in my code, and I found that it was caused by the search delegate holding on to the search bar and the table ref. If a set these properties to nil in searchDisplayControllerDidEndSearch then it got rid of the problem. It was likely caused by a circular ref loop. The stack trace looked like so:
[__NSArrayM _updateNoSearchResultsMessageVisiblity]: unrecognized selector sent to instance 0x21c350
#0 0x3369a1c8 in objc_exception_throw ()
#1 0x338b5aca in -[NSObject doesNotRecognizeSelector:] ()
#2 0x338b4944 in __forwarding__ ()
#3 0x3380f680 in _forwarding_prep_0__ ()
#4 0x30e5aff8 in -[UISearchResultsTableView _numberOfRowsDidChange] ()
#5 0x30d6c3b2 in -[UITableView noteNumberOfRowsChanged] ()
#6 0x30d6bf4e in -[UITableView reloadData] ()