*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[NSMutableArray objectAtIndex:]: index 18 beyond bounds [0 .. 16]'
*** Call stack at first throw:
(
0 CoreFoundation 0x02b11b99 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x02c6140e objc_exception_throw + 47
2 CoreFoundation 0x02b07695 -[__NSArrayM objectAtIndex:] + 261
3 MyPocket 0x0005efe9 -[loginLocalitems tableView:didSelectRowAtIndexPath:] + 638
4 UIKit 0x00be9a48 -[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:] + 1140
5 UIKit 0x00be032e -[UITableView _userSelectRowAtIndexPath:] + 219
6 Foundation 0x0037821a __NSFireDelayedPerform + 441
7 CoreFoundation 0x02af2f73 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 19
8 CoreFoundation 0x02af45b4 __CFRunLoopDoTimer + 1364
9 CoreFoundation 0x02a50dd9 __CFRunLoopRun + 1817
10 CoreFoundation 0x02a50350 CFRunLoopRunSpecific + 208
11 CoreFoundation 0x02a50271 CFRunLoopRunInMode + 97
12 GraphicsServices 0x03f4e00c GSEventRunModal + 217
13 GraphicsServices 0x03f4e0d1 GSEventRun + 115
14 UIKit 0x00b84af2 UIApplicationMain + 1160
15 MyPocket 0x000023d2 main + 84
16 MyPocket 0x00002375 start + 53
17 ??? 0x00000001 0x0 + 1
)
terminate called after throwing an instance of 'NSException'
What is the reason for the above array. This crash appears only when i select the lower cells of table view Anyone pls help
This error is telling you that your NSMutableArray has only from 0 to 16 objects inside. When you scroll to the bottom of the table and select the lower cell you are trying to access an object in the array at index higher then 16. So try to check if the array that you are using for the table is properly filled, and that you are not removing something from it at later time.
you are loading data from a mutable array?
check if the array really has 18 elements.
or if you are giving a number bigger than the actual row count in the numberOfRows inSection method
this is a range exception:
index 18 beyond bounds [0 .. 16]
as you see, it only occurs when you click the lower items
Related
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)];
I am getting the following error please help me with a solution. My xcode gets aborted with the following error
Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[NSMutableArray objectAtIndex:]: index 0 beyond bounds for empty array'
*** Call stack at first throw:
(
0 CoreFoundation 0x0140a5a9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x0155e313 objc_exception_throw + 44
2 CoreFoundation 0x014000a5 -[__NSArrayM objectAtIndex:] + 261
3 UMMCelebrity 0x00043903 -[UMMFlickrView photoGallery:urlForPhotoSize:atIndex:] + 115
4 UMMCelebrity 0x0004a9d6 -[FGalleryViewController createGalleryPhotoForIndex:] + 422
5 UMMCelebrity 0x0004a5ac -[FGalleryViewController loadThumbnailImageWithIndex:] + 172
6 UMMCelebrity 0x0004a189 -[FGalleryViewController preloadThumbnailImages] + 281
7 UMMCelebrity 0x00046f84 -[FGalleryViewController loadView] + 2132
8 UIKit 0x0029d00e -[UIViewController view] + 56
9 UMMCelebrity 0x00043050 -[UMMFlickrView pushphotoview] + 192
10 UMMCelebrity 0x000446c6 -[UMMFlickrView connection:didReceiveData:] + 2230
11 Foundation 0x00996835 _NSURLConnectionDidReceiveData + 159
12 CFNetwork 0x033bde72 _ZN19URLConnectionClient21_clientDidReceiveDataEPK8__CFDataPNS_26ClientConnectionEventQueueE + 262
13 CFNetwork 0x0348a6b3 _ZN19URLConnectionClient26ClientConnectionEventQueue33processAllEventsAndConsumePayloadEP20XConnectionEventInfoI12XClientEvent18XClientEventParamsEl + 247
14 CFNetwork 0x0348a9cf _ZN19URLConnectionClient26ClientConnectionEventQueue33processAllEventsAndConsumePayloadEP20XConnectionEventInfoI12XClientEvent18XClientEventParamsEl + 1043
15 CFNetwork 0x033b5c80 _ZN19URLConnectionClient13processEventsEv + 100
16 CFNetwork 0x033b5acf _ZN17MultiplexerSource7performEv + 251
17 CoreFoundation 0x013eb8ff __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
18 CoreFoundation 0x0134988b __CFRunLoopDoSources0 + 571
19 CoreFoundation 0x01348d86 __CFRunLoopRun + 470
20 CoreFoundation 0x01348840 CFRunLoopRunSpecific + 208
21 CoreFoundation 0x01348761 CFRunLoopRunInMode + 97
22 GraphicsServices 0x018e21c4 GSEventRunModal + 217
23 GraphicsServices 0x018e2289 GSEventRun + 115
24 UIKit 0x001fbc93 UIApplicationMain + 1160
25 UMMCelebrity 0x00001d29 main + 121
26 UMMCelebrity 0x00001ca5 start + 53
)
terminate called after throwing an instance of 'NSException'
You're calling objectAtIndex: with the argument 0 on an empty NSMutableArray.
[NSMutableArray objectAtIndex:]: index 0 beyond bounds for empty array
If you know the NSMutableArray can be empty, you should consider calling count on it to see if it does indeed contain any elements, before trying to access the elements.
Obviously, there's an empty NSMutableArray in -[UMMFlickrView photoGallery:urlForPhotoSize:atIndex:] and you sent it objectAtIndex: with argument 0.
That means your NSMutableArray is empty. I think you didn't allocate the memory for NSMutableArray. Read this link, it may be helpful for you.
http://www.roseindia.net/answers/viewqa/Mobile-Applications/14614-NSMutableArray-Example-Code.html
May be on the 4th click nothing is pushed into the array, I'm not sure as I have no idea what you are trying to do.If you can add the code line that adds the object into your array, we could help you.
This error is occurring because the array is empty for sure.
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.
I don't understand on how to debug this error message:
2011-02-01 20:45:56.151 NeMe[3206:207] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[NSMutableArray objectAtIndex:]: index 0 beyond bounds for empty array'
*** Call stack at first throw:
(
0 CoreFoundation 0x027deb99 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x0292e40e objc_exception_throw + 47
2 CoreFoundation 0x027d4695 -[__NSArrayM objectAtIndex:] + 261
3 NeighborMe 0x0000f617 -[NeighborMapViewController regionFromLocations] + 65
4 NeighborMe 0x0001047b -[NeighborMapViewController locationManager:didUpdateToLocation:fromLocation:] + 94
5 CoreLocation 0x02393870 -[CLLocationManager onClientEventLocation:] + 793
6 CoreLocation 0x0239218b OnClientEvent + 49
7 CoreLocation 0x023a8a83 _Z22CLClientInvokeCallbackP10__CLClient13CLClientEventPK14__CFDictionary + 47
8 CoreLocation 0x023a9b2c _Z27CLClientHandleDaemonDataFixP10__CLClientPK23CLDaemonCommToClientFixPK14__CFDictionary + 290
9 CoreLocation 0x023acb30 _Z24CLClientHandleDaemonDataP12__CFMachPortPvlS1_ + 1125
10 CoreFoundation 0x02720982 __CFMachPortPerform + 338
11 CoreFoundation 0x027bfff4 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
12 CoreFoundation 0x02720807 __CFRunLoopDoSource1 + 215
13 CoreFoundation 0x0271da93 __CFRunLoopRun + 979
14 CoreFoundation 0x0271d350 CFRunLoopRunSpecific + 208
15 CoreFoundation 0x0271d271 CFRunLoopRunInMode + 97
16 GraphicsServices 0x030bd00c GSEventRunModal + 217
17 GraphicsServices 0x030bd0d1 GSEventRun + 115
18 UIKit 0x002eeaf2 UIApplicationMain + 1160
19 NeighborMe 0x00002818 main + 102
20 NeighborMe 0x000027a9 start + 53
21 ??? 0x00000001 0x0 + 1
)
terminate called after throwing an instance of 'NSException'
There is NSMutableArray in this code... so how is this possible?
You have an empty array. You tried to call [array objectAtIndex:0]. 0 is beyond the bounds of an empty array (not surprising – anything is beyond the bounds for an empty array).
It means that early in [NeighborMapViewController regionFromLocations] you are attempting to index an NSMutableArray object. That array has zero elements in it -- it's empty. But you're apparently trying to access index 0, which would be the first element. Since there is no first element, you get an exception.
Probably the code that you expect to have executed to add items to the array has not yet executed, or you simply need to check the length of the array prior to trying to access the element at index 0. It's hard to say without knowing more about what you're doing.
gdb reports the offset as 65 bytes in to the function, so it's likely in one of the first few lines. You could probably manually inspect the code of the function to see, or set a breakpoint on the first line of the function and step through it.
I was seeing this error, however, not as an exception but only in the Issue Navigator. The solution was to simply restart XCode, then the error was gone.
As Kevin Ballard said, this error is thrown when you ask for the element at index X that is beyond array bounds, in addition to looking for [array objectAtIndex: X], this error may be even caused from the modern syntax array[X]
i've a problem with ios 4.2.1 and uidatepicker.
My app is running on iPad and the picker is inside an UIPopoverController.
On iOS 3.2 the app works fine.
When i spin any wheel of the picker, the app crash with this stack trace:
* Terminating app due to uncaught exception 'NSRangeException', reason: ' -[NSMutableArray objectAtIndex:]: index 2147483647 beyond bounds [0 .. 2]'
** Call stack at first throw:
(
0 CoreFoundation 0x01165be9 exceptionPreprocess + 185
1 libobjc.A.dylib 0x012ba5c2 objc_exception_throw + 47
2 CoreFoundation 0x0115b6e5 -[__NSArrayM objectAtIndex:] + 261
3 UIKit 0x002e9b74 -[UIPickerView reloadComponent:] + 62
4 UIKit 0x004cb6a9 -[UIDatePickerView _updateDateOrTime] + 1273
5 UIKit 0x004cb114 -[UIDatePickerView pickerView:didSelectRow:inComponent:] + 42
6 UIKit 0x002e9194 -[UIPickerView _sendSelectionChangedForComponent:] + 100
7 UIKit 0x002e8f75 -[UIPickerView scrollerDidEndSmoothScrolling:] + 75
8 UIKit 0x004924c7 -[UIScroller(Internal) _stopScrollingNotify:dealloc:pin:] + 692
9 UIKit 0x00493ed0 -[UIScroller(Static) _smoothScroll:] + 4743
10 UIKit 0x0048a188 ScrollerHeartbeatCallback + 129
11 GraphicsServices 0x01a9d447 HeartbeatTimerCallback + 35
12 CoreFoundation 0x01146fe3 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION + 19
13 CoreFoundation 0x01148594 __CFRunLoopDoTimer + 1220
14 CoreFoundation 0x010a4cc9 __CFRunLoopRun + 1817
15 CoreFoundation 0x010a4240 CFRunLoopRunSpecific + 208
16 CoreFoundation 0x010a4161 CFRunLoopRunInMode + 97
17 GraphicsServices 0x01a9a268 GSEventRunModal + 217
18 GraphicsServices 0x01a9a32d GSEventRun + 115
19 UIKit 0x0030242e UIApplicationMain + 1160
20 Agenda 0x0000245c main + 102
21 Agenda 0x000023ed start + 53
)
terminate called after throwing an instance of 'NSException'
Program received signal: “SIGABRT”.
Any ideas?
The problem is with your array range.