I am using NSFileManager on a secondary thread. I am using the defaultManager.
But during this processing its hard to imagine how the primary thread could possibly be using the defaultManager. Isn't the potential issue with NSFileManager that having two threads use it at the same time can cause problems. If only one thread uses it, that shouldn't cause a problem should it, even if its the secondary thread? I never cease to be amazed at how unthread safe Cocoa is. Stepping back... what I'm trying to do is copy a mess of files which is time consuming, while allowing the user to cancel. Currently a put up a window showing a progress indicator and allowing them to cancel. If they cancel I set the cancel flag for the background thread. What is the best design approach in Cocoa for this type of scenario? Should I avoid using a background thread and do all the processing via the run loop? I assume I'd then chunk the processing so that I copy one file at a time in some method invoked off the run loop, while allowing the UI to continue to run and cancel, setting some flag I check. If this is the preferred way to implement it, what is the best way to send a message to the run loop. Two ways that I've found so far are to: 1. use performSelectorOnMainThread or performSelector:delay: 2. Send a notification. When I process the notification, I copy the file and send myself another notification. Thanks for the suggestions and info. On Sat, Nov 8, 2008 at 4:01 PM, Adam R. Maxwell <[EMAIL PROTECTED]> wrote: > > On Nov 8, 2008, at 11:57 AM, David wrote: > >> My application is invoking NSFileManager copyPath:toPath:handler: >> It is possible that the user picked some weird value for toPath but it >> must exist because they picked it using NSOpenPanel. >> >> How or why can this be causing a crash? Especially inside >> NSFIleManager dealing with retain in a GC application? > > I notice you're crashing on thread 10. Do you instantiate a new > NSFileManager instance with alloc/init per thread? Using +[NSFileManager > defaultManager] from a background thread will cause problems (and note that > NSFileManager alloc/init doesn't work properly on 10.4 and earlier). > > -- > Adam > > _______________________________________________ Cocoa-dev mailing list ([email protected]) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
