Application Specific Information:
*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -'[__NSArrayM objectAtIndex:]: index 5 beyond bounds [0 .. 3]'
0 CoreFoundation __exceptionPreprocess + 124
1 libobjc.A.dylib objc_exception_throw + 56
2 CoreFoundation -[__NSArrayM removeObjectAtIndex:] + 0
3 UIKit -[UITableView cellForRowAtIndexPath:] + 252
4 someApp -[businessViewClass methodA:] (businessViewClass.m:298)
5 someApp -[businessViewClass scrollViewDidScroll:] (businessViewClass.m:292)
6 UIKit -[UIScrollView(UIScrollViewInternal) _notifyDidScroll] + 76
7 UIKit -[UIScrollView setContentOffset:] + 460
8 UIKit -[UITableView setContentOffset:] + 300
9 UIKit -[UIScrollView(UIScrollViewInternal) _adjustContentOffsetIfNecessary] + 60
10 UIKit -[UIScrollView setContentSize:] + 128
11 UIKit -[UITableView _applyContentSizeDeltaForEstimatedHeightAdjustments:] + 56
12 UIKit -[UITableViewRowData setHeight:forRowAtIndexPath:] + 572
13 UIKit __53-[UITableView _configureCellForDisplay:forIndexPath:]_block_invoke + 3016
14 UIKit +[UIView(Animation) performWithoutAnimation:] + 80
15 UIKit -[UITableView _configureCellForDisplay:forIndexPath:] + 460
16 UIKit -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:] + 788
17 UIKit -[UITableView _createPreparedCellForGlobalRow:willDisplay:] + 80
18 UIKit -[UITableView _updateVisibleCellsNow:isRecursive:] + 2360
19 UIKit -[UITableView cellForRowAtIndexPath:] + 136
20 someApp -[businessViewClass methodA:] (businessViewClass.m:298)
21 UIKit -[UIScrollView(UIScrollViewInternal) _notifyDidScroll] + 76
22 UIKit -[UIScrollView setContentOffset:] + 460
23 UIKit -[UITableView setContentOffset:] + 300
24 UIKit -[UIScrollView _smoothScrollWithUpdateTime:] + 2400
25 QuartzCore CA::Display::DisplayLinkItem::dispatch() + 40
26 QuartzCore CA::Display::DisplayLink::dispatch_items(unsigned long long, unsigned long long, unsigned long long) + 424
27 IOKit 0x000000018334de54 0x183348000 + 24148
28 CoreFoundation __CFMachPortPerform + 180
29 CoreFoundation __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 56
30 CoreFoundation __CFRunLoopDoSource1 + 436
31 CoreFoundation __CFRunLoopRun + 1800
32 CoreFoundation CFRunLoopRunSpecific + 384
33 GraphicsServices GSEventRunModal + 180
34 UIKit UIApplicationMain + 204
35 someApp main (main.m:15)
36 libdyld.dylib 0x0000000182b528b8 0x182b50000 + 10424
This is what happend.
I find an bug that exists in app online, but I can't reproduce it with project code. It seems a business method was called when scroll the UIScrollview, and this business method call cellForRowAtIndexPath method of UITableView, and then cellForRowAtIndexPath trigs the scrollViewDidScroll method of UIScrollView. And I call cellForRowAtIndexPath in scrollViewDiddScroll method. It comes back. but It doesn't recurrence because next method called is NSArrayM removeObjectAtIndex instead of trigging the ScrollViewDidScroll method of UIScrollView. and then NSRangeException occurred.
is there anybody meet this or any ideas? thank you.
Your numberOfRowsInSection method of tableview is returns value that is greater than your array of count.
array's count is 3 and you are accessing 5th object of array.
What you can do is put a check to avoid any such crash, just look at this example code. This will be helpful just in case you aren't able to reproduce it.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return self.yourArray.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (self.yourArray.count > indexPath.row)
{
// your code for the cell
}
return cell;
}
Your counting through an array but you are counting too far, thus not in bounds. You need to count the exact amount of units in the array.
Use this:
[_array count];
Related
I have code like this. When I debug with exception breakpoint, it crash when I reloadRow.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
if (section == 0)
return ceil(self.folders.count/ 2);
else if (section <= self.documents.count) {
DocumentsCollection *dc = self.documents[section - 1];
return dc.attachments.count;
}
return 0;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
//..........
[cell setData:dc.attachments[indexPath.row] andReload:^{
[tableView reloadRowsAtIndexPaths:#[indexPath] withRowAnimation:UITableViewRowAnimationNone];
}];
}
I am using constraint in my cell and all my data are really correct. I am trying to read error message and find in here too but I don't get it. Please kindly explain how I shall do. I totally don't understand why it say
"reason: '*** -[__NSArrayM objectAtIndex:]: index 4 beyond bounds [0 .. 3]'"
*** First throw call stack:
(
0 CoreFoundation 0x000000011334fd4b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x000000011252d21e objc_exception_throw + 48
2 CoreFoundation 0x00000001132812eb -[__NSArrayM objectAtIndex:] + 203
3 UIKit 0x0000000110c61df6 -[UITableView _existingCellForRowAtIndexPath:] + 159
4 UIKit 0x0000000110c8555c -[UITableView _heightForRowAtIndexPath:] + 109
5 UIKit 0x0000000110ebd783 -[UISectionRowData heightForRow:inSection:canGuess:] + 263
6 UIKit 0x0000000110ec5601 -[UITableViewRowData rectForRow:inSection:heightCanBeGuessed:] + 1016
7 UIKit 0x0000000110ec5707 -[UITableViewRowData rectForGlobalRow:heightCanBeGuessed:] + 142
8 UIKit 0x0000000110ec64b9 -[UITableViewRowData globalRowsInRect:canGuess:] + 1101
9 UIKit 0x0000000110fa5cf3 -[_UITableViewUpdateSupport(Private) _visibleRowRangePlusAdjoining] + 96
10 UIKit 0x0000000110fa5dc8 -[_UITableViewUpdateSupport(Private) _faultInRealHeightsOfNeededCells] + 138
11 UIKit 0x0000000110fb81c7 -[_UITableViewUpdateSupport _setupAnimations] + 164
12 UIKit 0x0000000110c544dd -[UITableView _updateWithItems:updateSupport:] + 3054
13 UIKit 0x0000000110c4c90f -[UITableView _endCellAnimationsWithContext:] + 17960
14 UIKit 0x0000000110c63f62 -[UITableView _updateRowsAtIndexPaths:updateAction:withRowAnimation:] + 331
15 UIKit 0x0000000126e4d4a2 -[UITableViewAccessibility reloadRowsAtIndexPaths:withRowAnimation:] + 73
16 iFeedback 0x000000010dc809ad __56-[DocumentVCWithFolder tableView:cellForRowAtIndexPath:]_block_invoke + 125
17 iFeedback 0x000000010dbeb6e8 -[DocumentDetailCell observeValueForKeyPath:ofObject:change:context:] + 552
18 Foundation 0x000000010f25bdec NSKeyValueNotifyObserver + 351
19 Foundation 0x000000010f25b687 NSKeyValueDidChange + 495
20 Foundation 0x000000010f33cb95 -[NSObject(NSKeyValueObservingPrivate) _changeValueForKeys:count:maybeOldValuesDict:usingBlock:] + 986
21 Foundation 0x000000010f220b01 -[NSObject(NSKeyValueObservingPrivate) _changeValueForKey:key:key:usingBlock:] + 60
22 Foundation 0x000000010f2e80df _NSSetSizeValueAndNotify + 285
23 UIKit 0x000000011144fa84 -[UICollectionView _updateVisibleCellsNow:] + 745
24 UIKit 0x0000000111456725 -[UICollectionView layoutSubviews] + 313
25 UIKit 0x0000000110bd2ab8 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1237
26 QuartzCore 0x00000001106e6bf8 -[CALayer layoutSublayers] + 146
27 QuartzCore 0x00000001106da440 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 366
28 UIKit 0x0000000110bc0928 -[UIView(Hierarchy) layoutBelowIfNeeded] + 1509
29 iFeedback 0x000000010dbeb4a9 -[DocumentDetailCell setUpTag] + 553
30 iFeedback 0x000000010dbeb24a -[DocumentDetailCell setData:andReload:] + 154
31 iFeedback 0x000000010dc8078b -[DocumentVCWithFolder tableView:cellForRowAtIndexPath:] + 1995
32 UIKit 0x0000000110c7b584 -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:] + 757
33 UIKit 0x0000000110c7b7e2 -[UITableView _createPreparedCellForGlobalRow:willDisplay:] + 74
34 UIKit 0x0000000110c4f2b0 -[UITableView _updateVisibleCellsNow:isRecursive:] + 3295
35 UIKit 0x0000000110c84b64 -[UITableView _performWithCachedTraitCollection:] + 110
36 UIKit 0x0000000110c6b3be -[UITableView layoutSubviews] + 222
37 UIKit 0x0000000110bd2ab8 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1237
38 QuartzCore 0x00000001106e6bf8 -[CALayer layoutSublayers] + 146
39 QuartzCore 0x00000001106da440 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 366
40 QuartzCore 0x00000001106da2be _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
41 QuartzCore 0x0000000110668318 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 280
42 QuartzCore 0x00000001106953ff _ZN2CA11Transaction6commitEv + 475
43 QuartzCore 0x0000000110695d6f _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 113
44 CoreFoundation 0x00000001132f4267 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
45 CoreFoundation 0x00000001132f41d7 __CFRunLoopDoObservers + 391
46 CoreFoundation 0x00000001132d8f8e __CFRunLoopRun + 1198
47 CoreFoundation 0x00000001132d8884 CFRunLoopRunSpecific + 420
48 GraphicsServices 0x0000000115340a6f GSEventRunModal + 161
49 UIKit 0x0000000110b0dc68 UIApplicationMain + 159
50 iFeedback 0x000000010dc60ebf main + 111
51 libdyld.dylib 0x00000001138da68d start + 1
)
I believe the Array the error is referring to is actually the queue of reusable cells that the UITableView maintain. When you call reloadRowsAtIndexPath, the tableView will ask its delegate for another cell at the same indexPath.
By adding a log into the first and last line of cellForRowAtIndexPath my log look something like:
Start for cell at [0, 9]
Start for cell at [0, 9]
End for cell at [0, 9]
End for cell at [0, 9]
Start for cell at [0, 10]
Start for cell at [0, 10]
End for cell at [0, 10]
End for cell at [0, 10]
Start for cell at [1, 0]
Start for cell at [1, 0]
End for cell at [1, 0]
End for cell at [1, 0]
Start for cell at [1, 1]
2017-01-10 16:48:05.530 TableView[25012:201598] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 8 beyond bounds [0 .. 7]'
which shows that if the completion handler of your setData gets called before the cellForRowAtIndexPath completes, your UITableView will attempt to call for one more cell then it has - note that my error says index 8 beyond bounds [0 .. 7] and my UITableView has got 8 visible cells.
To solve the problem, I suggest not calling reloadRowAtIndexPath but instead update the values of whatever display your cell contains directly.
your code is showing error because the block in which you are setting the data might be giving little bit delay.
The summary of what i meant is that you are reloading the table view from its delegate method. And the reloading is getting called from a block which might be the reason of crash.
You can do one thing, rather then reloading specific row, try to reload whole table.
Hope it will work.
Keep it simple.
Number of Row in every section should equal to objects in Array.
Suppose you pass 4 count in section 1 (which starts at index == 0) should equal to your Array objects.
It is crashing due to ROW count and Object in array is not matching.
If it not matched than you will get
"reason: '* -[__NSArrayM objectAtIndex:]: index 4 beyond bounds [0 .. 3]'"
Bounds [0..3] means Array has only 4 objects and it is trying to get 5th object at index 4.
Please check it and should has proper count in Array object.
Under what circumstances do UITableView give -1 or NSUIntegerMax for the row in -[UITableViewDelegate tableView:titleForDeleteConfirmationButtonForRowAtIndexPath:]?
Below it is a crash log form an user.
OS Version: iPhone OS 9.2.1 (13D15)
Application Specific Information:
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'no object at index 18446744073709551615 in section at index 0'
Last Exception Backtrace:
0 CoreFoundation 0x0000000181241900 __exceptionPreprocess + 124
1 libobjc.A.dylib 0x00000001808aff80 objc_exception_throw + 56
2 CoreData 0x0000000182cc50bc -[NSFetchedResultsController objectAtIndexPath:] + 456
3 My App 0x000000010022c678 -[MyViewController tableView:titleForDeleteConfirmationButtonForRowAtIndexPath:] (MyViewController.m:560)
4 UIKit 0x0000000186145174 -[UITableView _titleForDeleteConfirmationButtonForRowAtIndexPath:] + 160
5 UIKit 0x00000001862756f4 -[UITableView _deleteConfirmationButtonForRowAtIndexPath:] + 116
6 UIKit 0x0000000186275cf4 -[UITableView _swipeActionButtonsForRowAtIndexPath:] + 824
7 UIKit 0x0000000186275998 -[UITableView _swipeActionButtons] + 92
8 UIKit 0x0000000186144bd8 __32-[UITableViewCell _beginSwiping]_block_invoke + 120
9 UIKit 0x0000000185f42964 +[UIView(Animation) performWithoutAnimation:] + 80
10 UIKit 0x0000000186144b48 -[UITableViewCell _beginSwiping] + 96
11 UIKit 0x0000000186272320 -[UITableViewWrapperView handleSwipeBeginning:] + 256
12 UIKit 0x00000001864b4ea4 _UIGestureRecognizerSendTargetActions + 396
13 UIKit 0x00000001860d85b8 _UIGestureRecognizerSendActions + 172
14 UIKit 0x0000000185f669b0 -[UIGestureRecognizer _updateGestureWithEvent:buttonEvent:] + 784
15 UIKit 0x00000001864b63bc ___UIGestureRecognizerUpdate_block_invoke904 + 72
16 UIKit 0x0000000185f25b58 _UIGestureRecognizerRemoveObjectsFromArrayAndApplyBlocks + 372
17 UIKit 0x0000000185f228dc _UIGestureRecognizerUpdate + 2404
18 UIKit 0x0000000185f64820 -[UIWindow _sendGesturesForEvent:] + 1132
19 UIKit 0x0000000185f63e1c -[UIWindow sendEvent:] + 764
20 UIKit 0x0000000185f344cc -[UIApplication sendEvent:] + 248
21 UIKit 0x0000000185f32794 _UIApplicationHandleEventQueue + 5528
22 CoreFoundation 0x00000001811f8efc __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24
23 CoreFoundation 0x00000001811f8990 __CFRunLoopDoSources0 + 540
24 CoreFoundation 0x00000001811f6690 __CFRunLoopRun + 724
25 CoreFoundation 0x0000000181125680 CFRunLoopRunSpecific + 384
26 GraphicsServices 0x0000000182634088 GSEventRunModal + 180
27 UIKit 0x0000000185f9cd90 UIApplicationMain + 204
28 My App 0x00000001000a926c main (main.m:16)
29 ??? 0x0000000180cc68b8 0x0 + 0
- (NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath
{
MyMessage *message = [self messageAtIndex:indexPath.row];
if ([message.senderUid isEqualToString:mUid])
return NSLocalizedString(#"Delete", nil);
else
return NSLocalizedString(#"Hide", nil);
}
- (MyMessage *)messageAtIndex:(NSInteger)index
{
return [mMessagesController objectAtIndexPath:[NSIndexPath indexPathForRow:index inSection:0]];
}
indexPath.row and indexPath.section are each a NSUInteger (unsigned integer), which means that it's strictly positive. If you subtract and end up going negative, it jumps up to NSUIntegerMax. This makes it necessary to be careful with arithmetic involving index paths.
When you do row - 1 for row equal to zero, you will get NSUIntegerMax.
I guess the answer is: under no circumstance. If you're cell would be out of bounds the crash would display on rendering time, not when accessing [UITableViewDelegate tableView:titleForDeleteConfirmationButtonForRowAtIndexPath:]
So the issue has to do with trying to retrieve an object from mMessagesController. Try using:
- (MyMessage *)messageAtIndex:(NSInteger)index
{
return [[mMessagesController fetchedObjects] objectAtIndexPath:[NSIndexPath indexPathForRow:index inSection:0]];
}
or
- (MyMessage *)messageAtIndex:(NSInteger)index
{
return [mMessagesController objectAtIndex:index];
}
In Addition you could also filter the call to messageAtIndex to avoid going out of bounds.
- (NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.row < [mMessagesController fetchedObjects].count && indexPath.row >= 0) {
MyMessage *message = [self messageAtIndex:indexPath.row];
if ([message.senderUid isEqualToString:mUid])
return NSLocalizedString(#"Delete", nil);
else
return NSLocalizedString(#"Hide", nil);
} else {
return NSLocalizedString(#"Error", nil);
}
}
It is an iOS bug. Apple marked my bug as a duplicate of 23821434.
I am using a 4 UIButton that bring up the same UIPickerView but with different NSArray(4) appearing for each button. Using a 4 bool to let the UIPickerView to decide which to load, and which row's text to grab. The buttons methods just include the four bool properties, that sets the three to false and the correct one(button tapped) to true. Then UIViewAnimateWithDuration is called that brings up the UIPickerView (printed in a UIView - for both UIPickerView and UIToolbar to work together). All buttons are working just fine(no matter how many time I bring/close the UIPickerView)apart from one (even if it is pressed in first-middle-last-any order). Xcode throws the following exception:
What I did:
remove the button, create a new one
tried both storyboard/controller method of creating a button
added method to button using addtarget
linked button with method using storyboard
So what I am asking if anyone can see anything that I cannot see in my debugger's exception thrown:(sportCenter is a NSObject and it is not imported in this controller -tried that too!)
2015-11-05 13:14:36.356 -----[3975:1397857] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[sportCenter copyWithZone:]: unrecognized selector sent to instance 0x7f8709f62250'
*** First throw call stack:
(
0 CoreFoundation 0x0000000103673f45 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x00000001030eddeb objc_exception_throw + 48
2 CoreFoundation 0x000000010367c56d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3 CoreFoundation 0x00000001035c9eea ___forwarding___ + 970
4 CoreFoundation 0x00000001035c9a98 _CF_forwarding_prep_0 + 120
5 UIKit 0x0000000103c8954b -[UILabel _setText:] + 114
6 UIKit 0x0000000103a0580c -[UIPickerView tableView:cellForRowAtIndexPath:] + 863
7 UIKit 0x000000010429c146 -[UIPickerColumnView tableView:cellForRowAtIndexPath:] + 103
8 UIKit 0x0000000103b75e2a -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:] + 782
9 UIKit 0x0000000103b75f3f -[UITableView _createPreparedCellForGlobalRow:willDisplay:] + 74
10 UIKit 0x0000000103b4b307 -[UITableView _updateVisibleCellsNow:isRecursive:] + 3187
11 UIKit 0x0000000103b5d369 -[UITableView cellForRowAtIndexPath:] + 186
12 UIKit 0x000000010412419a -[UIPickerTableView selectRow:animated:notify:] + 342
13 UIKit 0x0000000103a0421f -[UIPickerView _resetSelectionOfTables] + 157
14 UIKit 0x0000000103a040ab __30-[UIPickerView layoutSubviews]_block_invoke + 9523
15 UIKit 0x0000000103ac9c10 +[UIView(Animation) performWithoutAnimation:] + 65
16 UIKit 0x0000000103a01b33 -[UIPickerView layoutSubviews] + 147
17 UIKit 0x0000000103a04fcb -[UIPickerView selectedRowInComponent:] + 45
18 UIKit 0x0000000103a0009e -[UIPickerView _updateSelectedRows] + 135
19 UIKit 0x0000000103a001cf -[UIPickerView didMoveToWindow] + 117
20 UIKit 0x0000000103acebe0 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 1768
21 UIKit 0x0000000103ace856 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 862
22 UIKit 0x0000000103ac3e2c __45-[UIView(Hierarchy) _postMovedFromSuperview:]_block_invoke + 155
23 Foundation 0x0000000102cc3d4a -[NSISEngine withBehaviors:performModifications:] + 155
24 UIKit 0x0000000103ac3d4a -[UIView(Hierarchy) _postMovedFromSuperview:] + 575
25 UIKit 0x0000000103ad17e7 -[UIView(Internal) _addSubview:positioned:relativeTo:] + 1967
26 --- 0x00000001026cbe7b -[AllOngoingViewController animatePickerView] + 107
27 --- 0x00000001026cbcd7 -[AllOngoingViewController centersAreTapped] + 71
28 UIKit 0x0000000103f0194f _UIGestureRecognizerSendTargetActions + 153
29 UIKit 0x0000000103efdfc1 _UIGestureRecognizerSendActions + 162
30 UIKit 0x0000000103efbfbe -[UIGestureRecognizer _updateGestureWithEvent:buttonEvent:] + 843
31 UIKit 0x0000000103f04283 ___UIGestureRecognizerUpdate_block_invoke898 + 79
32 UIKit 0x0000000103f04121 _UIGestureRecognizerRemoveObjectsFromArrayAndApplyBlocks + 342
33 UIKit 0x0000000103ef1bdd _UIGestureRecognizerUpdate + 2634
34 UIKit 0x0000000103a8f9c0 -[UIWindow _sendGesturesForEvent:] + 1137
35 UIKit 0x0000000103a90bf6 -[UIWindow sendEvent:] + 849
36 UIKit 0x0000000103a402fa -[UIApplication sendEvent:] + 263
37 UIKit 0x0000000103a1aabf _UIApplicationHandleEventQueue + 6844
38 CoreFoundation 0x00000001035a0011 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
39 CoreFoundation 0x0000000103595f3c __CFRunLoopDoSources0 + 556
40 CoreFoundation 0x00000001035953f3 __CFRunLoopRun + 867
41 CoreFoundation 0x0000000103594e08 CFRunLoopRunSpecific + 488
42 GraphicsServices 0x0000000106616ad2 GSEventRunModal + 161
43 UIKit 0x0000000103a2030d UIApplicationMain + 171
44 ----- 0x00000001026c1caf main + 111
45 libdyld.dylib 0x000000010a19e92d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
You must add your own copyWithZone: method in your objects...
However, I don't really understand your question / context. It looks designed in a bit complex way. Booleans array have chances to be a bad approach. It is better to have a selectedButton ( UIButton ) property in your controller, to know which one is selected, than maintain four booleans.
And finally, no matter the situation, if things are working for all objects, excepted the first one, it often means that you have an array index error somewhere.
I hope it helps.
UITableView in view controller. While reload the tableView two times and click cell it crash with different errors. I declare in .h interface.
{
UITableView *tblRestaurantList;
}
// also change to #property (nonatomic, retain)UITableView *tblRestaurantList;
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
return 0;
}
error reason : -[UITableViewCell tableView:heightForHeaderInSection:]
error reason : [_UIAppearanceCustomizableClassInfo tableView:heightForHeaderInSection:]
Sometime it shows EXC_BAD_ACCESS(code=EXC_i386_GPFLT) or __NSCFArray or [_CTNativeGlyphStorage tableView:heightForHeaderInSection:].(With 40 line error message)
I change the height to 1.0f, 0.0,0.0001f,1;
I don't what happen its run successfully in iOS 7. I saw many questions in StackOverflow but no one post exact answer.
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[_CTNativeGlyphStorage tableView:heightForHeaderInSection:]: unrecognized selector sent to instance 0x7fcdf0f1e6a0'
*** First throw call stack:
(
0 CoreFoundation 0x000000011376bf35 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x0000000112589bb7 objc_exception_throw + 45
2 CoreFoundation 0x000000011377304d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3 CoreFoundation 0x00000001136cb27c ___forwarding___ + 988
4 CoreFoundation 0x00000001136cae18 _CF_forwarding_prep_0 + 120
5 UIKit 0x0000000110ce1f4e -[UITableView _delegateWantsHeaderForSection:] + 261
6 UIKit 0x0000000110e66983 -[UISectionRowData refreshWithSection:tableView:tableViewRowData:] + 162
7 UIKit 0x0000000110e6ce45 -[UITableViewRowData rectForFooterInSection:heightCanBeGuessed:] + 320
8 UIKit 0x0000000110e6cf3a -[UITableViewRowData heightForTable] + 56
9 UIKit 0x0000000110cbfaf0 -[UITableView _updateContentSize] + 381
10 UIKit 0x0000000110cdcecd -[UITableView didMoveToWindow] + 65
11 UIKit 0x0000000110c639a0 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 1482
12 UIKit 0x0000000110c74333 -[UIScrollView _didMoveFromWindow:toWindow:] + 55
13 UIKit 0x0000000110c6368e -[UIView(Internal) _didMoveFromWindow:toWindow:] + 696
14 UIKit 0x0000000110c6368e -[UIView(Internal) _didMoveFromWindow:toWindow:] + 696
15 UIKit 0x0000000110c6368e -[UIView(Internal) _didMoveFromWindow:toWindow:] + 696
16 UIKit 0x0000000110c5c112 __45-[UIView(Hierarchy) _postMovedFromSuperview:]_block_invoke + 125
17 UIKit 0x0000000110c5c086 -[UIView(Hierarchy) _postMovedFromSuperview:] + 437
18 UIKit 0x0000000110c65f4b -[UIView(Internal) _addSubview:positioned:relativeTo:] + 1604
19 UIKit 0x0000000110be4bf1 __53-[_UINavigationParallaxTransition animateTransition:]_block_invoke + 2030
20 UIKit 0x0000000110c605ce +[UIView(Animation) performWithoutAnimation:] + 65
21 UIKit 0x0000000110be4072 -[_UINavigationParallaxTransition animateTransition:] + 1225
22 UIKit 0x0000000110d38e6c -[UINavigationController _startCustomTransition:] + 3038
23 UIKit 0x0000000110d443fe -[UINavigationController _startDeferredTransitionIfNeeded:] + 386
24 UIKit 0x0000000110d44f47 -[UINavigationController __viewWillLayoutSubviews] + 43
25 UIKit 0x0000000110e8a509 -[UILayoutContainerView layoutSubviews] + 202
26 UIKit 0x0000000110c68973 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 521
27 QuartzCore 0x0000000110347de8 -[CALayer layoutSublayers] + 150
28 QuartzCore 0x000000011033ca0e _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
29 QuartzCore 0x000000011033c87e _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
30 QuartzCore 0x00000001102aa63e _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 242
31 QuartzCore 0x00000001102ab74a _ZN2CA11Transaction6commitEv + 390
32 QuartzCore 0x00000001102abdb5 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 89
33 CoreFoundation 0x00000001136a0dc7 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
34 CoreFoundation 0x00000001136a0d20 __CFRunLoopDoObservers + 368
35 CoreFoundation 0x0000000113696b53 __CFRunLoopRun + 1123
36 CoreFoundation 0x0000000113696486 CFRunLoopRunSpecific + 470
37 GraphicsServices 0x00000001144d09f0 GSEventRunModal + 161
38 UIKit 0x0000000110bef420 UIApplicationMain + 1282
39 Restaurant 0x000000010f466193 main + 115
40 libdyld.dylib 0x0000000112c10145 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
I am using OS X Yosemite ver 10.10, xcode Version 6.1 (6A1052d), iPhone simulator iOS 8.1 (12B411).
Thanks in Advance
But why you put 0 in height ??
we can't put 0 here . if you do not want to put height for section, then don't put 0 in height.
This should be some value
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
return 4; // something like this
}
I just started creating a new checklist app for the first time.
So far I have added a Table View object and Table View Cell object to the app's UI in main.storyboard.
I then went to my View Controller header file and made sure to change the superclass type to "UITableViewController".
I then went to my View Controller main file and added the following methods:
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 1;
}
-(UITableViewCell *)tableview:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:#"ChecklistItem"];
return cell;
}
I keep getting a breakpoint error and cannot get the app to run on the iPhone simulator. I have tried starting from scratch and recreating this app 3 times now and have also tried using different simulators, and still nothing is working.
Whenever I try running the app this is the final output in the debug console:
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
Also, here is a link to a screenshot of what my xcode looks like when I try to run the program and get the breakpoint error: http://oi40.tinypic.com/25im3kn.jpg
I have gotten breakpoint errors many times in the past but usually can fix everything by just going to Debug > Deactivate Breakpoints but that is not working for me right now.
Any help is greatly appreciated thank you.
PS. Also, here is the entire output in the debug console log:
2013-12-18 18:25:55.183 Checklists[4910:70b] *** Assertion failure in -[UITableView _configureCellForDisplay:forIndexPath:], /SourceCache/UIKit_Sim/UIKit- 2903.23/UITableView.m:6246
2013-12-18 18:25:55.190 Checklists[4910:70b] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UITableView dataSource must return a cell from tableView:cellForRowAtIndexPath:'
*** First throw call stack:
(
0 CoreFoundation 0x017385e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x014bb8b6 objc_exception_throw + 44
2 CoreFoundation 0x01738448 +[NSException raise:format:arguments:] + 136
3 Foundation 0x0109bfee -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 116
4 UIKit 0x003123d5 __53-[UITableView _configureCellForDisplay:forIndexPath:]_block_invoke + 426
5 UIKit 0x0028b3ef +[UIView(Animation) performWithoutAnimation:] + 82
6 UIKit 0x0028b438 +[UIView(Animation) _performWithoutAnimation:] + 40
7 UIKit 0x00312226 -[UITableView _configureCellForDisplay:forIndexPath:] + 108
8 UIKit 0x0031863d -[UITableView _createPreparedCellForGlobalRow:withIndexPath:] + 442
9 UIKit 0x003186f3 -[UITableView _createPreparedCellForGlobalRow:] + 69
10 UIKit 0x002fc774 -[UITableView _updateVisibleCellsNow:] + 2378
11 UIKit 0x0030fe95 -[UITableView layoutSubviews] + 213
12 UIKit 0x00294267 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 355
13 libobjc.A.dylib 0x014cd81f -[NSObject performSelector:withObject:] + 70
14 QuartzCore 0x03b462ea -[CALayer layoutSublayers] + 148
15 QuartzCore 0x03b3a0d4 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
16 QuartzCore 0x03b46235 -[CALayer layoutIfNeeded] + 160
17 UIKit 0x0034f613 -[UIViewController window:setupWithInterfaceOrientation:] + 304
18 UIKit 0x0026e177 -[UIWindow _setRotatableClient:toOrientation:updateStatusBar:duration:force:isRotating:] + 5212
19 UIKit 0x0026cd16 -[UIWindow _setRotatableClient:toOrientation:updateStatusBar:duration:force:] + 82
20 UIKit 0x0026cbe8 -[UIWindow _setRotatableViewOrientation:updateStatusBar:duration:force:] + 117
21 UIKit 0x0026cc70 -[UIWindow _setRotatableViewOrientation:duration:force:] + 67
22 UIKit 0x0026bd0a __57-[UIWindow _updateToInterfaceOrientation:duration:force:]_block_invoke + 120
23 UIKit 0x0026bc6c -[UIWindow _updateToInterfaceOrientation:duration:force:] + 400
24 UIKit 0x0026c9c3 -[UIWindow setAutorotates:forceUpdateInterfaceOrientation:] + 870
25 UIKit 0x0026ffb6 -[UIWindow setDelegate:] + 449
26 UIKit 0x00341737 -[UIViewController _tryBecomeRootViewControllerInWindow:] + 180
27 UIKit 0x00265c1c -[UIWindow addRootViewControllerViewIfPossible] + 609
28 UIKit 0x00265d97 -[UIWindow _setHidden:forced:] + 312
29 UIKit 0x0026602d -[UIWindow _orderFrontWithoutMakingKey] + 49
30 UIKit 0x0027089a -[UIWindow makeKeyAndVisible] + 65
31 UIKit 0x00223cd0 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1851
32 UIKit 0x002283a8 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 824
33 UIKit 0x0023c87c -[UIApplication handleEvent:withNewEvent:] + 3447
34 UIKit 0x0023cde9 -[UIApplication sendEvent:] + 85
35 UIKit 0x0022a025 _UIApplicationHandleEvent + 736
36 GraphicsServices 0x036df2f6 _PurpleEventCallback + 776
37 GraphicsServices 0x036dee01 PurpleEventCallback + 46
38 CoreFoundation 0x016b3d65 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53
39 CoreFoundation 0x016b3a9b __CFRunLoopDoSource1 + 523
40 CoreFoundation 0x016de77c __CFRunLoopRun + 2156
41 CoreFoundation 0x016ddac3 CFRunLoopRunSpecific + 467
42 CoreFoundation 0x016dd8db CFRunLoopRunInMode + 123
43 UIKit 0x00227add -[UIApplication _run] + 840
44 UIKit 0x00229d3b UIApplicationMain + 1225
45 Checklists 0x00001b7d main + 141
46 libdyld.dylib 0x01d7670d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
PPS. After making your change, my view controller main file now looks like this:
#import "ChecklistsViewController.h"
#interface ChecklistsViewController ()
#end
#implementation ChecklistsViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 1;
}
-(UITableViewCell *)tableview:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:#"ChecklistItem"]; if(!cell) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:#"ChecklistItem"]; }
return cell;
}
#end
I still get an error and now this is what the console log is showing:
2013-12-18 18:42:14.609 Checklists[5014:70b] *** Assertion failure in -[UITableView _configureCellForDisplay:forIndexPath:], /SourceCache/UIKit_Sim/UIKit- 2903.23/UITableView.m:6246
2013-12-18 18:42:14.614 Checklists[5014:70b] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UITableView dataSource must return a cell from tableView:cellForRowAtIndexPath:'
*** First throw call stack:
(
0 CoreFoundation 0x017395e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x014bc8b6 objc_exception_throw + 44
2 CoreFoundation 0x01739448 +[NSException raise:format:arguments:] + 136
3 Foundation 0x0109cfee -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 116
4 UIKit 0x003133d5 __53-[UITableView _configureCellForDisplay:forIndexPath:]_block_invoke + 426
5 UIKit 0x0028c3ef +[UIView(Animation) performWithoutAnimation:] + 82
6 UIKit 0x0028c438 +[UIView(Animation) _performWithoutAnimation:] + 40
7 UIKit 0x00313226 -[UITableView _configureCellForDisplay:forIndexPath:] + 108
8 UIKit 0x0031963d -[UITableView _createPreparedCellForGlobalRow:withIndexPath:] + 442
9 UIKit 0x003196f3 -[UITableView _createPreparedCellForGlobalRow:] + 69
10 UIKit 0x002fd774 -[UITableView _updateVisibleCellsNow:] + 2378
11 UIKit 0x00310e95 -[UITableView layoutSubviews] + 213
12 UIKit 0x00295267 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 355
13 libobjc.A.dylib 0x014ce81f -[NSObject performSelector:withObject:] + 70
14 QuartzCore 0x03b472ea -[CALayer layoutSublayers] + 148
15 QuartzCore 0x03b3b0d4 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
16 QuartzCore 0x03b47235 -[CALayer layoutIfNeeded] + 160
17 UIKit 0x00350613 -[UIViewController window:setupWithInterfaceOrientation:] + 304
18 UIKit 0x0026f177 -[UIWindow _setRotatableClient:toOrientation:updateStatusBar:duration:force:isRotating:] + 5212
19 UIKit 0x0026dd16 -[UIWindow _setRotatableClient:toOrientation:updateStatusBar:duration:force:] + 82
20 UIKit 0x0026dbe8 -[UIWindow _setRotatableViewOrientation:updateStatusBar:duration:force:] + 117
21 UIKit 0x0026dc70 -[UIWindow _setRotatableViewOrientation:duration:force:] + 67
22 UIKit 0x0026cd0a __57-[UIWindow _updateToInterfaceOrientation:duration:force:]_block_invoke + 120
23 UIKit 0x0026cc6c -[UIWindow _updateToInterfaceOrientation:duration:force:] + 400
24 UIKit 0x0026d9c3 -[UIWindow setAutorotates:forceUpdateInterfaceOrientation:] + 870
25 UIKit 0x00270fb6 -[UIWindow setDelegate:] + 449
26 UIKit 0x00342737 -[UIViewController _tryBecomeRootViewControllerInWindow:] + 180
27 UIKit 0x00266c1c -[UIWindow addRootViewControllerViewIfPossible] + 609
28 UIKit 0x00266d97 -[UIWindow _setHidden:forced:] + 312
29 UIKit 0x0026702d -[UIWindow _orderFrontWithoutMakingKey] + 49
30 UIKit 0x0027189a -[UIWindow makeKeyAndVisible] + 65
31 UIKit 0x00224cd0 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1851
32 UIKit 0x002293a8 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 824
33 UIKit 0x0023d87c -[UIApplication handleEvent:withNewEvent:] + 3447
34 UIKit 0x0023dde9 -[UIApplication sendEvent:] + 85
35 UIKit 0x0022b025 _UIApplicationHandleEvent + 736
36 GraphicsServices 0x036e02f6 _PurpleEventCallback + 776
37 GraphicsServices 0x036dfe01 PurpleEventCallback + 46
38 CoreFoundation 0x016b4d65 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53
39 CoreFoundation 0x016b4a9b __CFRunLoopDoSource1 + 523
40 CoreFoundation 0x016df77c __CFRunLoopRun + 2156
41 CoreFoundation 0x016deac3 CFRunLoopRunSpecific + 467
42 CoreFoundation 0x016de8db CFRunLoopRunInMode + 123
43 UIKit 0x00228add -[UIApplication _run] + 840
44 UIKit 0x0022ad3b UIApplicationMain + 1225
45 Checklists 0x00002aed main + 141
46 libdyld.dylib 0x01d7770d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
The problem is that the code dequeueReusableCellWithIdentifier is not returning a cell.
Check if your cell in the XIB as the Reuse Identifier set to "ChecklistItem"
If the dequeueReusableCellWithIdentifier returns nil create a new cell.
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:#"ChecklistItem"];
if(!cell) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:#"ChecklistItem"];
}
That should fix your problem.