• 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: Cache Class review (low priority)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Cache Class review (low priority)


  • Subject: Re: Cache Class review (low priority)
  • From: Gregory Weston <email@hidden>
  • Date: Fri, 2 May 2008 07:37:27 -0400

Jens Alfke wrote:

On 1 May '08, at 4:49 PM, Western Botanicals wrote:

[NSTimer scheduledTimerWithTimeInterval: defaultSleepTime target:
self selector: @selector(run:) userInfo: nil repeats: YES];

That timer is autoreleased, so you have to retain it or it'll go away after your init method returns.

Not unless the docs are lying (and based on heavy timer usage in some of my apps, I'm going to claim they're not). From the NSTimer overview:


"Note in particular that run loops retain their timers, so you can release a timer after you have added it to a run loop."

That said, proper conformance to the memory contract would be that you *do* retain it if you do this...

Typically you'd then assign it to an ivar; then when you need to stop the
timer, you call -invalidate and -release on it.

But as long as the OP has no intention of manually invalidating the timer, what's already there is sufficient.
_______________________________________________


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


  • Follow-Ups:
    • Re: Cache Class review (low priority)
      • From: Jens Alfke <email@hidden>
  • Prev by Date: Re: drawing in a separate thread
  • Next by Date: Unit Test error XCode 3.1 (Beta)
  • Previous by thread: Re: Cache Class review (low priority)
  • Next by thread: Re: Cache Class review (low priority)
  • Index(es):
    • Date
    • Thread