App terminate due to - uncaught exception 'NSGenericException', - iphone

I got the below error while fetching some data from sever. While fetching data, i m displaying an custom alert view with activity indicator. Alert is using main thread while data fetching is done by NSThread. This problem occurs only at some time, not always. I m not able to understand what to do.
* Terminating app due to uncaught exception 'NSGenericException', reason: '* Collection was mutated while being enumerated.(
"",
"",
""
)'
* Call stack at first throw:
(
0 CoreFoundation 0x00f2abe9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x0107f5c2 objc_exception_throw + 47
2 CoreFoundation 0x00f2a6a9 __NSFastEnumerationMutationHandler + 377
3 UIKit 0x00371b8e -[UIView(Hierarchy) _findFirstSubviewWantingToBecomeFirstResponder] + 189
4 UIKit 0x00366a13 -[UIView(Hierarchy) _promoteDescendantToFirstResponderIfNecessary] + 42
5 MyApplnName 0x00015154 -[SecondViewController getDataFromServer] + 1798
6 Foundation 0x000a1d4c -[NSThread main] + 81
7 Foundation 0x000a1cd8 __NSThread__main__ + 1387
8 libSystem.B.dylib 0x928db7fd _pthread_start + 345
9 libSystem.B.dylib 0x928db682 thread_start + 34
)
terminate called after throwing an instance of 'NSException'

The problem is in part of your code where you enumerate some object, for example, NSMutableArray or NSMutableSet, using for-loop (for (id _obj in object)) and in that loop removing or adding some objects to the same object. It is not possible and causes exception.
You can replace that for-loop with for-loop using index variable:
for (int i=0; i<[object count]; i++)
{
//add or remove objects if you want
}

Related

pointCounts error using MKOverlay

I have problem with custom overlay. The problem is I cant identify error code, its occurs randomly
Maybe someone will be able to help me basic on this stack. What is pointCount?
2012-07-30 02:02:01.187 MyApp[454:8107] -[MyRegionOverlay pointCount]: unrecognized selector sent to instance 0x5d7dab0
2012-07-30 02:02:01.190 MyApp[454:8107] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[MyRegionOverlay pointCount]: unrecognized selector sent to instance 0x5d7dab0'
*** Call stack at first throw:
(
0 CoreFoundation 0x016c15a9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x01815313 objc_exception_throw + 44
2 CoreFoundation 0x016c30bb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
3 CoreFoundation 0x01632966 ___forwarding___ + 966
4 CoreFoundation 0x01632522 _CF_forwarding_prep_0 + 50
5 MapKit 0x008186c4 _ZL20createPathForPolygonP9MKPolygon10MKMapPoint + 55
6 MapKit 0x00818817 -[MKPolygonView createPath] + 95
7 MapKit 0x0081d715 -[MKOverlayPathView drawMapRect:zoomScale:inContext:] + 79
8 MapKit 0x00838328 -[MKOverlayClusterView drawLayer:inContext:] + 1450
9 QuartzCore 0x00472b5e -[CALayer drawInContext:] + 143
10 QuartzCore 0x00489283 _ZL18tiled_layer_renderP16_CAImageProviderjjjjPv + 1648
11 QuartzCore 0x003d1eb2 _ZL21CAImageProviderThreadPjb + 475
12 libSystem.B.dylib 0x91bce781 _pthread_wqthread + 390
13 libSystem.B.dylib 0x91bce5c6 start_wqthread + 30
)
What the error means is that there is an MKPolygonView in your overlay. The polygon property of the MKPolygonView is set to an instance of MyRegionOverlay. Unfortunately MyRegionOverlay is not a subclass of MKPolygon as it is supposed to be. So when the pointCount message is sent to the MyRegionOverlay you get a run time error "unrecognized selector" since MyRegionOverlay apparently does not respond to pointCount.

Why sometimes my application stops working and gives Program received signal: “SIGABRT” error?

I have four views in my navigational based application. MainView, AddView, ShowView and DetailView. MainView has a NSMutableArray. When i click on button add, then i go to AddView and then i add an object in NSMutable array of MainView. Then i come back and go to ShowView which is a tableView. From MainView i am calling createList function of ShowView like this:
ShowView *show = [[ShowView alloc] init];
[show createList: self.savedObjectsList];
[self.navigationController pushViewController: show animated: YES];
[runListController release];
In ShowView createList looks like this:
- (void) createRunsList: (NSMutableArray *) list{
objList = [list retain];
}
where objList is NSMutableArray in ShowView. every cell of table view creates a DetailView of an object of NSMutbaleArray. Problem is sometimes my applications stop working and i get this error:
2011-10-03 15:35:55.076 RunnoIPhoneApp[2750:707] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[NSMutableArray objectAtIndex:]: index 0 beyond bounds for empty array'
*** Call stack at first throw:
(
0 CoreFoundation 0x3399964f __exceptionPreprocess + 114
1 libobjc.A.dylib 0x30b16c5d objc_exception_throw + 24
2 CoreFoundation 0x33904069 -[__NSArrayM objectAtIndex:] + 184
3 RunnoIPhoneApp 0x0000b79f -[PostRunDetailViewController createRunDetail:] + 90
4 RunnoIPhoneApp 0x0000fd2f -[RunListViewController tableView:didSelectRowAtIndexPath:] + 182
5 UIKit 0x3203f51b -[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:] + 662
6 UIKit 0x320a30eb -[UITableView _userSelectRowAtPendingSelectionIndexPath:] + 130
7 Foundation 0x32ba26d5 __NSFireDelayedPerform + 368
8 CoreFoundation 0x33970a47 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 14
9 CoreFoundation 0x33972ecb __CFRunLoopDoTimer + 850
10 CoreFoundation 0x33973845 __CFRunLoopRun + 1088
11 CoreFoundation 0x33903ec3 CFRunLoopRunSpecific + 230
12 CoreFoundation 0x33903dcb CFRunLoopRunInMode + 58
13 GraphicsServices 0x3162e41f GSEventRunModal + 114
14 GraphicsServices 0x3162e4cb GSEventRun + 62
15 UIKit 0x32019d69 -[UIApplication _run] + 404
16 UIKit 0x32017807 UIApplicationMain + 670
17 RunnoIPhoneApp 0x00002553 main + 70
18 RunnoIPhoneApp 0x00002508 start + 40
)
terminate called after throwing an instance of 'NSException'
Program received signal: “SIGABRT”.
warning: Unable to read symbols for /Developer/Platforms/iPhoneOS.platform/DeviceSupport/4.3.5 (8L1)/Symbols/Developer/usr/lib/libXcodeDebuggerSupport.dylib (file not found).
Program received signal: “SIGABRT”.
(gdb)
Can anybody tell me why is it happening? DetailView of some first objects works fine but then i get this error. Thanks in advance.
Looking at the stack trace, the exception is thrown in your [PostRunDetailViewController createRunDetail:] method, which is called when you select a row in your RunListViewController's UITableView. You are trying to access an element in the array that is out of bounds.
Put a break point at the start of this method and step through it in the debugger. Work out which array access is causing the exception and then think why the array might not contain the elements that you expect.
Just comment this line
[runListController release];

Crash in tableview cell

*** 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

Implementing mobFox causes crash

Just trying to implement mobFox into my app, but having trouble to make it run. I suspect that it is because of my general approach not to use IB at all, because the sample code works just fine.
After run it is pointing to the line
int retVal = UIApplicationMain(argc, argv, nil, #"UntitledAppDelegate");
which is in my main.m,
with this as result
2011-04-18 16:07:48.000 BinTeeth[10141:bf07] -[NSCFString md5]: unrecognized selector sent to instance 0x622ef40
2011-04-18 16:07:48.001 BinTeeth[10141:bf07] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSCFString md5]: unrecognized selector sent to instance 0x622ef40'
*** Call stack at first throw:
(
0 CoreFoundation 0x014845a9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x015d8313 objc_exception_throw + 44
2 CoreFoundation 0x014860bb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
3 CoreFoundation 0x013f5966 ___forwarding___ + 966
4 CoreFoundation 0x013f5522 _CF_forwarding_prep_0 + 50
5 BinTeeth 0x0002d90f -[MobFoxBannerView asyncRequestAdWithPublisherId:] + 177
6 Foundation 0x00670cf4 -[NSThread main] + 81
7 Foundation 0x00670c80 __NSThread__main__ + 1387
8 libSystem.B.dylib 0x9758c85d _pthread_start + 345
9 libSystem.B.dylib 0x9758c6e2 thread_start + 34
)
terminate called after throwing an instance of 'NSException'
any help would be appreciated, I have tried many things, but nothing really looks loke solution for me so far
tnx
Did you set the linker-flags as described in the SDK documentation?
Best

index 0 beyond bounds for empty array error

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]