Objective-C can be a difficult mistress at the best of times, but I've been pulling my hair out over the useless exception traces it gives when my iPhone app falls over. For example:

2009-06-02 22:22:39.036 GPSDraw[31024:20b] *** -[CLLocation timeIntervalSinceReferenceDate]: unrecognized selector sent to instance 0x40add0
2009-06-02 22:22:39.038 GPSDraw[31024:20b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[CLLocation timeIntervalSinceReferenceDate]: unrecognized selector sent to instance 0x40add0'
2009-06-02 22:22:39.039 GPSDraw[31024:20b] Stack: (

Which is all very exciting, but how about telling me the line of my code that threw the exception? That's what any sane IDE would do, but XCode is different and prefers to give an unhelpful list of numbers instead. The stack that the debugger shows is always just some arbitrary point in the main run loop, with the only bit of my code in scope being main.

However I've stumbled across the crucial way to get the behaviour that should be enabled by default. Whilst debugging, select Run > Manage Breakpoints > Add Symbolic Breakpoint. Now enter "objc_exception_throw" without the quotes and it should actually break at the point in your code that the exception is thrown.


  1. OK, good info. BUT more importantly, WTF is up with that exception? I’m getting this same BS, and nowhere in my code do I call timeIntervalSinceReference date. I’m doing some work with NSDates and CLLocations, but obviously I’m not calling that method on a CLLocation. What was the story in your case?

  2. That being 2.5 years ago and my memory being like a sieve, I’m afraid I haven’t a clue. I can’t even remember writing that blog post to be honest, though that’s why I write them frankly – because I know I tend to forget stuff. I can only apologise for not also writing up what was causing my exception. Sorry.
    I presume that the error message tells no lies and that somehow that erroneous call is being made.

You must be logged in to leave a reply.