How do you print out a stack trace to the console/log in Cocoa?

robottobor picture robottobor · Oct 21, 2008 · Viewed 87.8k times · Source

I'd like to log the call trace during certain points, like failed assertions, or uncaught exceptions.

Answer

smokris picture smokris · Feb 24, 2010
 NSLog(@"%@",[NSThread callStackSymbols]);

This code works on any thread.