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: (
    2532991147,
    2419396155,
    2533020330,
    2533013676,
    2533013874,
    2532962733,
    23499,
    22944,
    2520474771,
    2532494021,
    2532494456,
    827745792,
    827745989,
    816114848,
    816160924,
    11116,
    10970
)

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.

2 Comments

  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.

Leave a Reply

Your email address will not be published. Required fields are marked *