Re: Problem using filewrappers under snow leopard - SOLVED
Re: Problem using filewrappers under snow leopard - SOLVED
- Subject: Re: Problem using filewrappers under snow leopard - SOLVED
- From: Eagle Offshore <email@hidden>
- Date: Wed, 14 Oct 2009 09:44:44 -0700
I thought I'd share the underlying cause. In prior versions of OS X,
if the contents of the file was nil, NSFileWrapper would just create
an empty file. No problem. Empty file.
Under Snow Leopard, NSFileWrapper writing aborts cryptically if any of
the files' contents are nil or the wrapper is empty. My app allows
the creation of optional rich text data to be saved with each "song"
but if the user didn't touch the text editor, then it gives back nil
rather than empty data.
Thus, - write failure. Apparently we now have to check for nil data
when creating a file wrapper even though this was OK before for the
past couple OS versions. Also, empty file wrappers don't work either
but sticking one non-nil thing in works. So, I've added a check for
nil before adding an item to the wrapper.
Filed a bug 7302406
- (NSFileWrapper *)fileWrapperOfType:(NSString *)aType error:
(NSError**)errPtr
{
int i, count = [_songs count];
NSFileWrapper* wrapper = [[NSFileWrapper alloc]
initDirectoryWithFileWrappers:nil];
[wrapper addRegularFileWithContents:[self setData]
preferredFilename:@"Sets.plist"];
for(i = 0; i < count; ++i)
{
JBSong* song = [_songs objectAtIndex: i];
[wrapper addRegularFileWithContents: [song asData]
preferredFilename: [[song fileName] stringByAppendingPathExtension:
@"sng"]];
NSData* lyrics = [song lyricData];
if(lyrics)
{
[wrapper addRegularFileWithContents: [song lyricData]
preferredFilename: [[song fileName] stringByAppendingPathExtension:
@"rtf"]];
}
}
[wrapper addRegularFileWithContents:[NSKeyedArchiver
archivedDataWithRootObject: _midiController]
preferredFilename:@"Midi.map"];
return [wrapper autorelease];
}
-Todd Blanchard
_______________________________________________
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