title: what's the correct way to store an NSURL in Core Data?
body: <p>I'm trying to archive / unarchive NSManagedObjectIDs in Core Data objects so that next time my app starts up I can retrieve these IDs and use them to fetch specific objects.</p>
  
  <p>I tried "archiving" the ID like this:</p>
  
  <pre><code>//defaultConfiguration is an NSManagedObject defined elsewhere and it works just fine...    
  // and newObject is also properly initialized, bound to a context,etc...
  
  ArchivedID* newID = [NSEntityDescription insertNewObjectForEntityForName:@"ArchivedID" inManagedObjectContext:managedObjectContext];
  [self.defaultConfiguration addArchiveIDObject:newID];
  newID.idURI = [[newObject objectID] URIRepresentation];
  [managedObjectContext save:&amp;error]; 
  </code></pre>
  
  <p>And then unarchiving like this (I'm just going for [anyObject] cause i'm testing and there's only one at this point):</p>
  
  <pre><code>NSManagedObjectID* ID = [managedObjectContext.persistentStoreCoordinator managedObjectIDForURIRepresentation:[defaultConfiguration.archiveID anyObject]];
  </code></pre>
  
  <p>But when I try getting the URL back like above, I get the following exception:</p>
  
  <pre><code>Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[ArchivedID relativeString]: unrecognized selector sent to instance 0x7f59f20'
  </code></pre>
  
  <p>The attribute in the entity was set up through Xcode to "transformable" and I left the transformer value field in Xcode empty since the Core Data documentation seems to imply if empty it's use the default transformer.</p>
  
  <p>What am I doing wrong?</p>