• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSTimer retains its target ???
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

References: 
 >NSTimer retains its target ??? (From: Tobias Hermann <email@hidden>)

  • Prev by Date: NSTimer retains its target ???
  • Next by Date: How get version of app from propertyList.plc runtime?
  • Previous by thread: NSTimer retains its target ???
  • Next by thread: How get version of app from propertyList.plc runtime?
  • Index(es):
    • Date
    • Thread