title: NSFileWrapper fails when from iCloud and works from local directory
body: <p>I have a problem syncing NSFileWrapper documents with iCloud. I am able to create my wrapper and save it to my ubiquitous container.</p>
  
  <p>When I try to read it from the device that created it, it works. When I try to read form another device that got it from iCloud, it crashes.</p>
  
  <p>Some code:</p>
  
  <p>This function to add a wrapper container with a NSString</p>
  
  <pre><code>- (void) addNSString:(NSString*)_string toFileWrapper:(NSFileWrapper*)_wrapper forKey:(NSString*)_key {
  
      NSData *data = [NSKeyedArchiver archivedDataWithRootObject:_string];
  
      if(data) {
  
          [_wrapper addRegularFileWithContents:data preferredFilename:_key];
      }
  </code></pre>
  
  <p>}</p>
  
  <p>And then here is how I decode it:</p>
  
  <pre><code>- (id) unarchiveObjectFromWrappers:(NSDictionary*)_wrappers withKey:(NSString*)_key {
  
      id value = nil;
  
      NSFileWrapper *wrapper = [_wrappers valueForKey:_key];
      if(wrapper) {
  
          NSData *data = [wrapper regularFileContents];
  
          if(data) {
  
              value = [NSKeyedUnarchiver unarchiveObjectWithData:data];
          }
      }
  
      return value;
  }
  </code></pre>
  
  <p>The decoding part works on one device and not on the others (EXC_BAD_ACCESS when the NSKeyedUnarchiver tries to unarchive from the NSData. The NSData seems good, it has the proper length and everything but when I try to log its datas for example it crashes).</p>
  
  <p>My guess is that the NSFileWrapper doesn't download its full content, only its structure and that I have to do something to make it available. But I don't know what.</p>
  
  <p>Any ideas?</p>
  
  <p>========</p>
  
  <p>Edit:</p>
  
  <p>NSURLUbiquitousItemIsDownloadedKey says that the file is downloaded BUT if I try to copy it to the sandbox it fails with this error: "The operation couldn’t be completed. Bad file descriptor"</p>
  
  <p>So the file is either not uploaded properly to iCloud or not downloaded properly...</p>