• 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: NSFileManager thread safety?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSFileManager thread safety?


  • Subject: Re: NSFileManager thread safety?
  • From: Gregory Weston <email@hidden>
  • Date: Mon, 16 Nov 2009 07:07:19 -0500

David Cake wrote:

> The following code snippet works fine from my main thread.
> 	 NSFileManager *tempFileManager = [[NSFileManager alloc] init];
> 	 NSString *path= [self tempDirPath];
> 	 if(![tempFileManager  removeItemAtPath: path  error: nil]) {
> 	 NSLog(@"failed to remove temp files");
> 	 }
> [tempFileManager release];
>
> But from within
> -(NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication
> *)sender
> or other delegate methods, it gets my EXC_BAD_ACCESS on the
> removeItemAtPath call
> - any suggestions? I thought NSFileManager was supposed to be
> thread-safe in 10.5 and 10.6?


Given Dave Keck's correct comment that threading shouldn't even come up in the situation you describe, I should point out that according to the docs the result of sending init to an NSFileManager object in 10.5 is undefined. If you're testing there, it's entirely legit for tempFileManager to be invalid after the first line executes.
_______________________________________________

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: NSFileManager thread safety?
      • From: Joar Wingfors <email@hidden>
  • Prev by Date: Re: SFAuthorization
  • Next by Date: Re: retain and don`t retain in accessor methods
  • Previous by thread: Re: NSFileManager thread safety?
  • Next by thread: Re: NSFileManager thread safety?
  • Index(es):
    • Date
    • Thread