Not exactly an answer, but it might help. This methods will give you a printout of stack or of caller in debug area. You can modify them of course to use the values as you please.
Code is kind of 'stolen' but i have no reference to where from.
#define SHOW_STACK NSLog(@"%@",[NSThread callStackSymbols])
#define SHOW_CALLER \
do { \
NSArray *syms = [NSThread callStackSymbols]; \
if ([syms count] > 1) { \
NSLog(@"<%@ %p> %@ - caller: %@ ", [self class], self, NSStringFromSelector(_cmd),[syms objectAtIndex:1]); \
} else { \
NSLog(@"<%@ %p> %@", [self class], self, NSStringFromSelector(_cmd)); \
} \
} while(0)
EDIT: you would probably want something like this:
NSString *caller = nil;
NSArray *syms = [NSThread callStackSymbols];
if (syms.count > 1)
{
caller = syms[1];
}
if (caller.length)
{
NSLog(@"%s called by %@",
__PRETTY_FUNCTION__,
caller);
}
There is another Q&A here on SO you might find very useful.