iOS Uncaught Exception Handler not getting called - ios

I have a similar situation to Uncaught exception handler not called but his is a Mac application and mine is an iOS app. The solution was to use ExceptionHandler framework but that is not available on iOS.
I have a brand new iOS single view application and it is only a few lines of code so I won't paste my whole file.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions: (NSDictionary *)launchOptions
{
NSSetUncaughtExceptionHandler(&handler);
#throw NSInternalInconsistencyException;
return YES;
}
void handler()
{
NSLog(#"hello world");
}
So in didFinishLaunchingWithOptions I set my custom exception handler and then force a crash. The exception handler is then meant to print hello world to the console but that does not happen. Putting break points in the handler shows that execution does not enter the method. However the exception gets printed to the console anyway (default action).
2014-07-24 08:58:25.476 Exception[430:70b] *** Terminating app due to uncaught exception of class '__NSCFConstantString'
libc++abi.dylib: terminating with uncaught exception of type __NSCFConstantString
Could there be another exception handler being set by default after my handler somewhere?
UPDATE
I decided to change how I force the crash from NSInternalInconsistencyException to [[NSArray arrayWithObject:#"object"] objectAtIndex:1];. The handler is now being called and hello world is being printed to the console.
So the question now is, why did NSINternalInconsistencyException not cause the handler to be called? The error is slightly different:
2014-07-24 10:13:51.333 Exception[1474:70b] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayI objectAtIndex:]: index 1 beyond bounds [0 .. 0]'
*** First throw call stack:
...
...
...
libc++abi.dylib: terminating with uncaught exception of type NSException

Related

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Can't cancel on a touch that isn't already active!'

I have an error message when I tap very quickly in a TextView into a TableView. It crashes and gives me the error message :
*** Assertion failure in -[_UIKBRTRecognizer notifyDelegateOfCancelledTouch:],
/BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit/UIKit-3600.5.2/Keyboard/_UIKBRTRecognizer.m:996
2017-01-14 18:17:18.558043 Formbox_Dacia_BE_Bruxelles_2017[317:15523]
*** Assertion failure in -[_UIKBRTRecognizer notifyDelegateOfCancelledTouch:], /BuildRoot/Library/
Terminating app due to uncaught exception
'NSInternalInconsistencyException', reason: 'Can't cancel on a touch that isn't already active!'
*** First throw call stack:
(0x1e00ae07 0x1d26b077 0x1e00ace1 0x1e8de0f1 0x236fbeb3 0x236fa3f1 0x3f6d67 0x402ed9 0x3fa215 0x404de1 0x404be9 0x1d866937 0x1d86648c)
libc++abi.dylib: terminating with uncaught exception of type
NSException
Any ideas ?
EDIT: It seems that it is when I click on the keyboard selection, and I press on a keyboard touch for info.

Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArray0 objectAtIndex:]

I am trying to run app on the iphone 6 and I get this error. I get the error after making the facebook login. Normally, it is working successfully on the simulator. I couldn't find why it gives the error.
Error:
*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArray0 objectAtIndex:]: index 0 beyond bounds for empty NSArray'
*** First throw call stack:
(0x181dcae38 0x18142ff80 0x181d41a6c 0x100418620 0x100417aa0 0x10042dbac 0x10006a3a0 0x10006aa0c 0x186f14b40 0x186f14744 0x1872ba9fc 0x1872774f4 0x187273f04 0x1871c6fd8 0x1871d4990 0x186f064a4 0x181d807b0 0x181d7e554 0x181d7e984 0x181ca8d10 0x183590088 0x186f7df70 0x10008810c 0x1818468b8)
libc++abi.dylib: terminating with uncaught exception of type NSException
Since you posted no stack trace, I assume you want to learn how to find bugs like this. First, in Xcode, set a breakpoint on Objective-C exceptions, so you find where exactly the crash happens.
The error says clearly that you are trying to access array [0] for an NSArray that is empty. Once you find the location of the crash that should be easy to find.

how to know which NSArray is causing the exception

My iOS app is crashing with the following error message. Basically, I am trying to access an array index that is not present.
How do I get Xcode to show me the exact array name on which I did the wrong operation (or the call stack leading up the crash)?
****Error message I see***
2015-11-05 09:24:38.509 firstCDapp[1165:734714] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArray0 objectAtIndex:]: index 0 beyond bounds for empty NSArray'
*** First throw call stack:
(0x279c585b 0x39086dff 0x27958bdf 0x923f9 0x2be38d63 0x2be38e89 0x2be28df5 0x2be3d46f 0x2bbe35af 0x2baf5cc3 0x2b3bdb05 0x2b3b9201 0x2b3b9091 0x2b3b85b1 0x2b3b8263 0x2b3b1a1f 0x27988091 0x27986387 0x279867c5 0x278d90d9 0x278d8ecd 0x30c4eaf9 0x2bb622dd 0x93b35 0x397d4873)
libc++abi.dylib: terminating with uncaught exception of type NSException
Try to add an Exception Breakpoint -> right click -> edit -> Exception = Obj-c, this can help you to find the error

NSRangeException error - In-App-Purchase implemantaition

I've implemented an In-App-Purchase into my app.
If I run my app and press the "purchase" button, i get the following error:
2014-10-22 17:48:20.733 MyApp[170:3435] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayI objectAtIndex:]: index 0 beyond bounds for empty array'
Does someone got the same error and know what's to do?
It is the typical exception that emerges when handling an empty array.
Add an exception breakpoint to your project in Xcode, as shown in the picture.
It will stop the execution of the app in the line that the exception does happen

App is Crashing when clicking UINavigation back button ios?

When i tried to click one button it moved to next UIViewcontroller and from there i click back button and it came back to the previous UIViewcontroller ,suddently it crashed.
Following are the crash report
2013-08-19 12:02:19.849 MyApp[851:907] *** Terminating app due to uncaught exception 'NSGenericException', reason: '*** Collection <CALayerArray: 0x1f1f1120> was mutated while being enumerated.' *** First throw call stack: (0x34a1d2a3 0x3c67797f 0x34a1cd85 0x36827ca3 0x36827d33 0x36827d33 0x36827d33 0x36827d33 0x36827b9b 0x36a0b585 0x368538af 0x368a3f19 0x3683aab3 0x368af8ef 0x365e4c01 0x3ca8e4b7 0x3ca8fdcb 0x349f0f3b 0x34963ebd 0x34963d49 0x384e02eb 0x36879301 0xdc439 0xdc3c0) libc++abi.dylib: terminate called throwing an exception

Resources