Re: Getting NSTimer to work after an NSThread completes?
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