Re: NSTimer problem
Re: NSTimer problem
- Subject: Re: NSTimer problem
- From: Keary Suska <email@hidden>
- Date: Wed, 16 Jan 2008 17:55:01 -0700
- Thread-topic: NSTimer problem
on 1/16/08 3:22 PM, email@hidden purportedly said:
You are leaking objects like mad.
> timer = [[NSTimer alloc] initWithFireDate:[NSDate
> dateWithTimeIntervalSinceNow:currentInterval]
> interval:currentInterval target:self
You *do* know that above you are setting your object property, and not a
local variable?
> -(void)setTimer:(NSTimer*)tm{
>
> [timer autorelease];
> timer = [tm retain];
> }
Here you are retaining an alloced object after autoreleasing it, so it will
never be released. If you don't know why, re-read the "cocoa memory
management guidelines" (again?).
This will probably not solve your problem. It is likely that the problem
lies in code that you aren't showing, such as how the timer is being created
in the first place.
Also:
> Stepping through the debugger, I see that when inside my invalidate
> function, the timer is null, 0x0.
It always will, the first time. Once it has been created, it should no
longer be null.
Best,
Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden