iphone - How can I get information about who called a method? -
I'm called a special method, want to get some information about this. That is, if possible, get the method number and file name to call. Except for a level in the stack, it is possible in high-level languages like FILE and line , but what is the purpose of doing this in Objective-C?
- (zero) myMethod {NSLog (@ "me file% @, line #% i", callingfile, callingline); }
No, no. You will have to tell the user to pass the code to __ file __
and __ line __
. Define my myth: # myfethod myMethodWithFile: __ FILE__ line: __l LINE__ ... - (zero) myMethodWithFile: (const char *) file line: (int) line {nslog (@ File% s, called by line #% D, file, line);} ... [obj myMethod];
Comments
Post a Comment