{"id":3450,"date":"2014-03-25T11:24:53","date_gmt":"2014-03-25T11:24:53","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/25\/how-do-you-print-out-a-stack-trace-to-the-console-log-in-cocoa-collection-of-common-programming-errors\/"},"modified":"2014-03-25T11:24:53","modified_gmt":"2014-03-25T11:24:53","slug":"how-do-you-print-out-a-stack-trace-to-the-console-log-in-cocoa-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/25\/how-do-you-print-out-a-stack-trace-to-the-console-log-in-cocoa-collection-of-common-programming-errors\/","title":{"rendered":"How do you print out a stack trace to the console\/log in Cocoa?-Collection of common programming errors"},"content":{"rendered":"<p>I found this to be exactly what I needed: Puts a catch in the main.m class and prints the stack trace. I am not sure it works in all situations, e.g. not sure this will work when there&#8217;s a C level crash. But, better than nothing, and easy to install.<\/p>\n<p>http:\/\/blog.evergizmo.com\/2012\/01\/17\/objective-c-tip-how-to-print-stack-trace\/<\/p>\n<p>In case the link goes away &#8211; put this in main.m:<\/p>\n<pre><code>#import \n\nint main(int argc, char *argv[]) \n{    \n    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];\n\n    int retVal;\n    @try \n    {\n        retVal = UIApplicationMain(argc, argv, nil, @\"AppDelegate\");\n    }\n    @catch (NSException *exception) \n    {\n        NSLog(@\"Gosh!!! %@\", [exception callStackSymbols]);\n        @throw;\n    }\n    @finally \n    {\n        [pool release];\n    }\n    return retVal;\n}\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>I found this to be exactly what I needed: Puts a catch in the main.m class and prints the stack trace. I am not sure it works in all situations, e.g. not sure this will work when there&#8217;s a C level crash. But, better than nothing, and easy to install. http:\/\/blog.evergizmo.com\/2012\/01\/17\/objective-c-tip-how-to-print-stack-trace\/ In case the link [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-3450","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/3450","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=3450"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/3450\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=3450"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=3450"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=3450"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}