Search code examples
ioscore-datansmanagedobjectid

Core data object id format


I have these permanent object ids that I got by fetching the same object in different contexts:

<x-coredata://F1697911-CD8A-4D63-B40F-AB0CA020C873/Facility/p1>
<x-coredata://F1697911-CD8A-4D63-B40F-AB0CA020C873/Facility/p2>

The GUID part F1697911-CD8A-4D63-B40F-AB0CA020C873is the same.
The entity part is the same.

What is p1 and p2 and why are they different?

my expectation is that the objects they represent should be the same.. I use them across different managed object contexts, but from what I understand the object id should be the same.

thanks.


Solution

  • The p identifies the objectID as persistent, associated to its MOC. It is part of the whole URI.

    Temporary URIs look different, e.g.: x-coredata:///Facility/tF1697911-CD8A-4D63-B40F-AB0CA020C873 notice the "t" in front of the objectID.

    That's just how CoreData's url scheme works.

    You have 2 persistent unique IDs to differentiate the object references.