Re: Problems saving NSDictionary with writeToFile
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.