开发者

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

开发者 https://www.devze.com 2022-12-15 12:02 出处:网络
This question already has answers here: How to find out who called a method? (9 answers) Closed 8 years ago.
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

精彩评论

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

关注公众号