How to print a stack trace anytime in iOS (#iosdev, #iosdevtips)

This really came in handy recently, when I wanted to see a stack trace in the console, and not from the result of an exception! Thanks to this tip found at Bynomial Code, I was able to accomplish this amazingly easily.

As mentioned in the blog, it requires iOS 4.0+, which, from my perspective, is everyone.

Bynomial Code » Print a stack trace anytime

Print a stack trace anytime Here’s how to print a stack trace from code at any point in your app – no need to wait for a crash report! –

NSLog(@"%@", [NSThread callStackSymbols]);