I'm making a document-based Cocoa app in which the document is dynamic a collection of files (users can add or remove files). In particular, the Save and Open operations should be as fast as possible.
If I understand the documentation correctly, I should use NSFileWrapper
and implement fileWrapperOfType:error
and readFromFileWrapper:ofType:error:
. However, I can't find a complete code example. How should I implement the following methods?
#pragma mark - NSDocument
- (NSFileWrapper *)fileWrapperOfType:(NSString *)typeName error:(NSError **)outError {
return nil;
}
- (BOOL)readFromFileWrapper:(NSFileWrapper *)fileWrapper ofType:(NSString *)typeName error:(NSError **)outError {
return YES;
}
#pragma mark - My methods
- (void) addFileToDocumentFromURL:(NSURL*)fileURL {
// Add a file to the document given the file URL
}
- (void) removeFileFromDocumentWithName:(NSString*)name {
// Remove a file from the document given the file name
}