Overriding NSDocument's fileWrapperOfType causes "Document could not be saved."
I've got to be missing something s开发者_如何学运维imple, but Google is not helping.
My file saves and loads fine. (I've overridden dataOfType
to get some stuff in it.) Then I override fileWrapperOfType
(in preparation for creating a bundle), and I get a "The document 'Untitled' could not be saved as 'test'." sheet when I try to save. Even when I empty out my method to the absolute most basic form I can think of...
- (NSFileWrapper*)fileWrapperOfType:(NSString*)typeName error:(NSError**)outError
{
NSFileWrapper* worldWrapper = [[NSFileWrapper alloc] initDirectoryWithFileWrappers:nil];
return [worldWrapper autorelease];
}
...I still can't save. What am I missing?
From the docs (emphasis mine):
The dictionary must contain entries whose values are the file wrappers that are to become children and whose keys are filenames.
You use nil
so my guess is that worldWrapper
is nil
, and returning nil
is interpreted as not being able to save your file.
精彩评论