-1

Is there any way that I can list all called methods like there are called one after the other? For example now I am doing same thing in way that I'm putting NSLog(@"MethodName"); i every that method. I want to do that by automatic way in NSLog. Is it possible?

iWizard
  • 6,816
  • 19
  • 67
  • 103

3 Answers3

1

If you don't have too much methods you can use

NSLog(@"%@" , NSStringFromSelector(_cmd));

to log their names. This way you don't have to copy the signatures manually each time.

Attila H
  • 3,616
  • 2
  • 24
  • 37
1

Create a property 'NSMutableArray *calledMethods;`

And in each of your method use

[self.calledMethods addObject:NSStringFromSelector(_cmd)];

And whenever you want to print it NSLog it.

Anoop Vaidya
  • 46,283
  • 15
  • 111
  • 140
1

I think you want:

printf("%s\n", __PRETTY_FUNCTION__ ) ;

Which produces (for example)

-[AppDelegate application:didFinishLaunchingWithOptions:]

Or, you can use dtrace. This answer should help: https://stackoverflow.com/a/3874726/210171.

Also check https://stackoverflow.com/a/4604249/210171 (same linked question). Seems there's an environment variable NSObjCMessageLoggingEnabled you can set...

Community
  • 1
  • 1
nielsbot
  • 15,922
  • 4
  • 48
  • 73