title: NSURL into NSData (Cocoa error 256.)
body: <p>I need to serialize my NSURL.</p>
  
  <p>object is type of NSManagedObject.</p>
  
  <pre><code>NSURL *objectURIRepresentation = [[object objectID] URIRepresentation];
  NSError *error = nil;
  NSData *objectIDData = [NSData dataWithContentsOfURL:objectURIRepresentation options:NSDataReadingMapped error:&amp;error];
  </code></pre>
  
  <p>I get error: (Cocoa error 256.).
  Any ideas? Something tells me, using <code>dataWithContentsOfURL:</code> is not good idea.</p>
  
  <p><strong>Update</strong></p>
  
  <p>One more question which is put as a comment mistakenly:</p>
  
  <p>What is the difference between <code>[NSData dataWithContentsOfURL:uri];</code> and <code>[NSKeyedArchiver archivedDataWithRootObject:uri];</code>?</p>
  
  <p>Thanks.</p>