开发者

How can I determine the "caller" of my method in Objective-C? [duplicate]

This question already has answers here: How to find out who called a method? (9 answers) Closed 8 years ago.

So I have a rather complex application that I've, perhaps naively, agreed to开发者_StackOverflow中文版 "debug". Upon entering into a certain method, I'd like to print out as much info about who called the method, from which class, method, etc. it was called from. Any suggestions would be very much appreciated!!


Just add in your method:

NSLog(@"Show stack trace: %@", [NSThread callStackSymbols]);


For debugging you could use a debugger :) put a breakpoint in the method and view the backtrace.

You could also scatter NSLog statements with relevant information in methods.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜