How can I get core data entity by it's objectID?

后端 未结 2 1524
生来不讨喜
生来不讨喜 2021-01-17 10:37

I have a list objects from coredata and then I get objectId from one of those objects:

let fetchedId = poi.objectID.URIRepresentation()

Now

2条回答
  •  失恋的感觉
    2021-01-17 11:11

    What you get is not the object ID, but the URI. The object ID is a part of the URI. You can ask the persistent store coordinator for the object ID with - managedObjectIDForURIRepresentation:. Having the object ID you can get the object from the context using for example -objectWithID:. But please look to the documentation, of this methods for some reasons.

提交回复
热议问题