views:

19

answers:

1

Hi I have seen a few examples of adding breakpoints in gdb using the command fb. I have tried using the following but it doesn't work...

fb -[NSTimer release]

I tried it but it says.

Function "-[NSTimer release]" not defined.

As you can probably tell I want the debugger to stop when release is called on any NSTimer object.

How can I create the breakpoint I want on [NSTimer release]?

Thanks!

+1  A: 

More likely than not, NSTimer doesn't actually implement -release, opting to inherit said method from the superclass.

Now, one solution would be to add something like this:

 @interface NSTimer(FooBar)
 @end
 @implementation NSTimer(FooBar)
 -(void) release {
      [super release];
  }
  @end

To your project somewhere. The you could set a breakpoint.

However, I wouldn't bother. Instead, you can use the Allocations Instrument to see each and every retain/release event against a particular object, often far more useful than just the releases (especially considering that there may be dozens of NSTimer objects coming/going in an application).

bbum
Followed your advice... I used instruments Allocations and found that I wasn't assigning through the property (should have used self like this self.timer=t;) but I was releasing by setting nil to the property (self.timer=nil;) leading to overrelease. To find this information I had to make sure "Record reference counts" in Allocations was turned on. Thanks!
Cal