• 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: Problems saving NSDictionary with writeToFile
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problems saving NSDictionary with writeToFile


  • Subject: Re: Problems saving NSDictionary with writeToFile
  • From: "Sven A. Schmidt" <email@hidden>
  • Date: Mon, 10 Feb 2003 13:25:05 +0100

This might not help you, but I've had a similar problem yesterday, where I tried the following:

- (void)writeAtPathNoGo: (NSString *)path {
NSFileHandle *fh = [ NSFileHandle fileHandleForWritingAtPath: path ];
NS_DURING
[ fh writeData: [ self data ]];
[ fh closeFile ];
NS_HANDLER
NSLog( @"failure writing file %@", path );
NS_ENDHANDLER
}

As the method name indicates, this doesn't work (no trace of a file). 'path' is ok, as is '[self data]' (of type NSData). There's no exception. Using the following instead works fine:

- (void)writeAtPath: (NSString *)path {
BOOL success = [[ self data ] writeToFile: path atomically: NO ];
if ( success ) {
NSLog( @"file written to: %@", path );
} else {
NSLog( @"write failure" );
}
}

So maybe there are odd and even Macs and for you it works the other way around by using NSFileHandle?

Puzzled,
Sven

On Montag, Februar 10, 2003, at 03:28 Uhr, Colin Cornaby wrote:

No, I'm quite sure the file never makes it, and this is re-produceable on other machines. The path I am passing in my app is /Test2.xscheme (and I have tried /Users/ColinCornaby/Test2.xscheme). The permissions are ok, and the method has worked before, but not on this specific instance. The app will be handling much larger situations too. Both flags for atomically also make no difference.

--Colin Cornaby
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: Problems saving NSDictionary with writeToFile (From: Colin Cornaby <email@hidden>)

  • Prev by Date: Re: iCal calendar parser
  • Next by Date: Re: Create a custom control (widget)
  • Previous by thread: Re: Problems saving NSDictionary with writeToFile
  • Next by thread: Terminating an NSThread from another thread
  • Index(es):
    • Date
    • Thread