{"id":1793,"date":"2009-06-02T22:36:09","date_gmt":"2009-06-02T22:36:09","guid":{"rendered":"http:\/\/justthesam.com\/2009\/06\/iphone-app-debugging-stop-on-exception\/"},"modified":"2009-06-02T22:36:09","modified_gmt":"2009-06-02T22:36:09","slug":"iphone-app-debugging-stop-on-exception","status":"publish","type":"post","link":"https:\/\/justthesam.com\/?p=1793","title":{"rendered":"iPhone app debugging: stop on exception"},"content":{"rendered":"<div>Objective-C can be a difficult mistress at the best of times, but I&#39;ve been pulling my hair out over the useless exception traces it gives when my iPhone app falls over. For example:<\/div>\n<p><\/p>\n<div>\n<div><span style=\"font-family: Courier;\">2009-06-02 22:22:39.036 GPSDraw[31024:20b] *** -[CLLocation timeIntervalSinceReferenceDate]: unrecognized selector sent to instance 0x40add0<\/span><\/div>\n<div><span style=\"font-family: Courier;\">2009-06-02 22:22:39.038 GPSDraw[31024:20b] *** Terminating app due to uncaught exception &#39;NSInvalidArgumentException&#39;, reason: &#39;*** -[CLLocation timeIntervalSinceReferenceDate]: unrecognized selector sent to instance 0x40add0&#39;<\/span><\/div>\n<div><span style=\"font-family: Courier;\">2009-06-02 22:22:39.039 GPSDraw[31024:20b] Stack: (<\/span><\/div>\n<div><span style=\"font-family: Courier;\">&#0160;&#0160; &#0160;2532991147,<\/span><\/div>\n<div><span style=\"font-family: Courier;\">&#0160;&#0160; &#0160;2419396155,<\/span><\/div>\n<div><span style=\"font-family: Courier;\">&#0160;&#0160; &#0160;2533020330,<\/span><\/div>\n<div><span style=\"font-family: Courier;\">&#0160;&#0160; &#0160;2533013676,<\/span><\/div>\n<div><span style=\"font-family: Courier;\">&#0160;&#0160; &#0160;2533013874,<\/span><\/div>\n<div><span style=\"font-family: Courier;\">&#0160;&#0160; &#0160;2532962733,<\/span><\/div>\n<div><span style=\"font-family: Courier;\">&#0160;&#0160; &#0160;23499,<\/span><\/div>\n<div><span style=\"font-family: Courier;\">&#0160;&#0160; &#0160;22944,<\/span><\/div>\n<div><span style=\"font-family: Courier;\">&#0160;&#0160; &#0160;2520474771,<\/span><\/div>\n<div><span style=\"font-family: Courier;\">&#0160;&#0160; &#0160;2532494021,<\/span><\/div>\n<div><span style=\"font-family: Courier;\">&#0160;&#0160; &#0160;2532494456,<\/span><\/div>\n<div><span style=\"font-family: Courier;\">&#0160;&#0160; &#0160;827745792,<\/span><\/div>\n<div><span style=\"font-family: Courier;\">&#0160;&#0160; &#0160;827745989,<\/span><\/div>\n<div><span style=\"font-family: Courier;\">&#0160;&#0160; &#0160;816114848,<\/span><\/div>\n<div><span style=\"font-family: Courier;\">&#0160;&#0160; &#0160;816160924,<\/span><\/div>\n<div><span style=\"font-family: Courier;\">&#0160;&#0160; &#0160;11116,<\/span><\/div>\n<div><span style=\"font-family: Courier;\">&#0160;&#0160; &#0160;10970<\/span><\/div>\n<div><span style=\"font-family: Courier;\">)<\/span><\/div>\n<p><\/p>\n<div><span style=\"font-weight: bold;\">Which is all very exciting, but how about telling me the line of my code that threw the exception?<\/span> That&#39;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.<\/div>\n<p><\/p>\n<div>However I&#39;ve <a href=\"http:\/\/www.cocoadev.com\/index.pl?DebuggingTechniques\" target=\"_blank\" rel=\"noopener\">stumbled across<\/a> the crucial way to get the behaviour that should be enabled by default. Whilst debugging, select Run &gt; Manage Breakpoints &gt; Add Symbolic Breakpoint. Now enter &quot;<span style=\"font-family: Helvetica; line-height: 16px; \">objc_exception_throw&quot; without the quotes and it should actually break at the point in your code that the exception is thrown.<\/span><\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Objective-C can be a difficult mistress at the best of times, but I&#39;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 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16,22,33],"tags":[],"class_list":["post-1793","post","type-post","status-publish","format-standard","hentry","category-mac","category-programming","category-webtech"],"_links":{"self":[{"href":"https:\/\/justthesam.com\/index.php?rest_route=\/wp\/v2\/posts\/1793","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/justthesam.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/justthesam.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/justthesam.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/justthesam.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1793"}],"version-history":[{"count":0,"href":"https:\/\/justthesam.com\/index.php?rest_route=\/wp\/v2\/posts\/1793\/revisions"}],"wp:attachment":[{"href":"https:\/\/justthesam.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1793"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/justthesam.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1793"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/justthesam.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1793"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}