title: Using NSFileWrapper in NSDocument made of various files
body: <p>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, <strong>the Save and Open operations should be as fast as possible</strong>.</p>
  
  <p>If I understand the documentation correctly, I should use <a href="https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ApplicationKit/Classes/NSFileWrapper_Class/Reference/Reference.html" rel="noreferrer"><code>NSFileWrapper</code></a> and implement <a href="http://developer.apple.com/library/mac/documentation/Cocoa/Reference/ApplicationKit/Classes/NSDocument_Class/Reference/Reference.html#//apple_ref/occ/instm/NSDocument/fileWrapperOfType:error:" rel="noreferrer"><code>fileWrapperOfType:error</code></a> and <a href="http://developer.apple.com/library/mac/documentation/Cocoa/Reference/ApplicationKit/Classes/NSDocument_Class/Reference/Reference.html#//apple_ref/occ/instm/NSDocument/readFromFileWrapper:ofType:error:" rel="noreferrer"><code>readFromFileWrapper:ofType:error:</code></a>. However, I can't find a complete code example. How should I implement the following methods?</p>
  
  <pre><code>#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
  }
  </code></pre>