Reputation: 4938
Ok, i have a requirement to set a breakpoint that only gets "hit" when a method is (or is not) called by a specific object and/or selector
the easiest way i can think of doing that is if there were some compiler macro (like _cmd) that unwinds the stack and returns the id and selector of the immediate caller of the current method.
eg assuming the majical macros were _cmd_caller_id & _cmd_caller_sel) -
if ( (_cmd_caller_id == self) && (_cmd_caller_sel != @selector(some_method:signature:) ) {
NSLog(@"called by %@ - hitting breakpoint",NSStringFromSelector(_cmd_caller_sel));
}
(and you would put a break point on the line containing the NSLog(...); );
the reason being i have a method that is called many times, an i need to be able to set up a more complex set of conditions than i have described above to set a trap to determine what method is calling the offending method and when.
Upvotes: 4
Views: 428
Reputation: 16861
Set your breakpoint at the calling site, with a condition on the breakpoint (e.g. self == whatever)
Upvotes: 3