NSManagedObjectID into NSData

前端 未结 6 2165
一生所求
一生所求 2020-12-30 06:27

I found this wonderful NSManagedObjectID. This would be very good for referencing an Entity/NSManagedObject/NSEntityDescription, right?
Let\'s get an ID from an entity:<

6条回答
  •  半阙折子戏
    2020-12-30 06:56

    From the NSManagedObjectID documentation:

    Object IDs can be transformed into a URI representation which can be archived and recreated later to refer back to a given object (using managedObjectIDForURIRepresentation: (NSPersistentStoreCoordinator) and objectWithID: (NSManagedObjectContext). For example, the last selected group in an application could be stored in the user defaults through the group object’s ID. You can also use object ID URI representations to store “weak” relationships across persistent stores (where no hard join is possible).

    Just turn it into a URL then turn that into a string or a data.

提交回复
热议问题