• 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: Getting NSTimer to work after an NSThread completes?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Getting NSTimer to work after an NSThread completes?


  • Subject: Re: Getting NSTimer to work after an NSThread completes?
  • From: "Michael Ash" <email@hidden>
  • Date: Tue, 7 Oct 2008 11:46:44 -0400

On Tue, Oct 7, 2008 at 4:42 AM, Jason Coco <email@hidden> wrote:
> Your notification is getting dispatched to the wrong thread. If you can
> target 10.5, do this:
>
> [[NSRunLoop mainRunLoop] addTimer:myNSTimer forMode:NSDefaultRunLoopMode];

Please *don't* do this. NSRunLoop is not thread safe, and so cannot be
used from any thread other than the one it's in charge of. Either use
CFRunLoop instead (CFRunLoop is thread safe, CFRunLoopTimer is
toll-free bridged to NSTimer) or use performSelectorOnMainThread: to
get some code running on the main thread, then add the timer from
there.

Mike
_______________________________________________

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

References: 
 >Getting NSTimer to work after an NSThread completes? (From: Alex Reynolds <email@hidden>)
 >Re: Getting NSTimer to work after an NSThread completes? (From: Jason Coco <email@hidden>)

  • Prev by Date: [Meeting] Toronto Area Cocoa and WebObjects Developer Group - October 21
  • Next by Date: Re: defaultCenter's addObserver
  • Previous by thread: Re: Getting NSTimer to work after an NSThread completes?
  • Next by thread: CoreData: Fetching object with maximum of property
  • Index(es):
    • Date
    • Thread