Re: NSTimer retains its target ???
Re: NSTimer retains its target ???
- Subject: Re: NSTimer retains its target ???
- From: j o a r <email@hidden>
- Date: Tue, 29 Apr 2003 11:44:29 +0200
On Tuesday, Apr 29, 2003, at 11:21 Europe/Stockholm, Tobias Hermann
wrote:
That is really strange, because I thought TARGETS simply are
references! And the target I pass here is the creator of the Timer, so
it also makes no sense that the Timer retains its parent ?!
...but the timer object doesn't know what a "parent" is, or who is
creating it, so it cannot make that kind of decision.
Problem is that I want to invalidate the timer within the dealloc
method of the target. But that now never gets called because the timer
retained it :-(
Is that a bug or am I misunderstanding something ?
It's working per design, so it's not a bug.
I have created a separate scheduler class that doesn't retain it's
targets for similar purposes, you might do the same if you can't
re-design your code. Something like this:
@interface MyScheduler : NSObject
{
@private
NSMutableSet *events;
}
+ (void) addSubscriber:(id) subscriber toAction:(SEL) action
afterDelay:(NSTimeInterval) secondsDelay;
+ (void) removeSubscriber:(id) subscriber;
@end
j o a r
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.