0

Possible Duplicate:
How to find out who called a method?

I have multiple classes and multiple methods calling a method on a singleton class. I want to know which method is calling, without passing a flag. I am already passing self to child I know which class is calling using [classObj class]; But I could not figure out how to identify which method is calling it.

Community
  • 1
  • 1
pa12
  • 1,493
  • 4
  • 19
  • 40
  • 5
    As a side note, this feels like a bad pattern and you should reanalyze why you need to do this. – Shizam Feb 04 '13 at 20:23

1 Answers1

0

Although I definitely recommend against doing this (Pass a flag as you suggest yourself), here's how you would see one level up in your call stack:

NSLog(@"%@", [[NSThread callStackSymbols] objectAtIndex:1]);
max_
  • 24,076
  • 39
  • 122
  • 211
James Boutcher
  • 2,593
  • 1
  • 25
  • 37