You can set a conditional breakpoint in Xcode by setting a breakpoint in normal mode, then right-clicking on it and select โEdit breakpointโ (choose Run โ Show โ breakpoints).
The breakpoint entry has a Condition column.
Now there are a few issues that should be considered provided. Firstly, gdb does not understand the dot syntax, so instead of myObj.name you should use [myObj name] (if the name is not ivar).
Next, like most expressions in gdb, you must specify the type of the return result, namely "BOOL". So set a condition like this:
(BOOL)[[myObj name] isEqualToString:@"Bar"]
It is often actually actually easier to just do this in code by temporarily adding code, for example:
if ( [myObj.name isEqualToString:@"Bar"] ) { NSLog( @"here" ); }
and then set a breakpoint in NSLog. Then your condition can be arbitrarily complex without worrying about what gdb can and cannot analyze.
Peter N Lewis Jun 13 '09 at 2:53 2009-06-13 02:53
source share