Re: Works in main Thread, but not in background Thread (modified)
Re: Works in main Thread, but not in background Thread (modified)
- Subject: Re: Works in main Thread, but not in background Thread (modified)
- From: "Jason Foreman" <email@hidden>
- Date: Wed, 7 Jan 2009 09:32:57 -0600
Hi John,
On Wed, Jan 7, 2009 at 9:01 AM, John Love <....> wrote:
> NSWorkspace *workSpace = [NSWorkspace sharedWorkspace];
> Let me wrap this up by saying when myRoutine is called in my main thread,
> everything works fine .. but when called by my background thread (via
> [NSThread detachNewThreadSelector:toTarget:withObject:] it definitely does
> not work.
There was a discussion recently on Twitter of all places regarding the
thread safety of various Cocoa classes. Thread safety includes
non-main thread usability, and it was determined that many Cocoa
classes aren't safe to use on non-main threads. It's possible that
NSWorkspace falls into this category. The solution for NSFileManager
was to alloc/init a new one on the thread[1], but I'm not sure if that
will work for NSWorkspace. Otherwise you're forced to make all those
calls on the main thread.
Typically, if a class isn't documented as thread-safe, that implies it
is only main-thread safe as well.
Jason
[1] Tweet from Dave Dribin: http://twitter.com/ddribin/status/1097936172
_______________________________________________
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