Saving NSManagedObjectID from one object as a property for another object?

I have a Core Data Entity object that needs to be held on NSManagedObjectIDanother object. To do this, I considered converting ObjectID to a string, which is an approved attribute type NSManagedObject.

I can read from the documentation that I can get a URI representation of the identifier:

NSURL *uriID = [[myEntity objectID] URIRepresentation];

Then I can convert this URL to NSString with:

NSString *stringID = [uriID absoluteString];

This can be stored in my NSManagedObjectNSString attribute .

Now, what happens when I need to go the other way?

I would like to do something like this:

if([myManagedObject objectID] == value) 

where the value is that NSManagedObjectIDwhich was previously converted to NSString.

, : Entity hold ObjectID Entity, : "" Entity.

, - :)

+3
1

" " Object, interaction, Entity - , to-many Entity Object interactions? , .

-managedObjectIDForURIRepresentation: +URLWithString:, .

+7

Source: https://habr.com/ru/post/1728804/


All Articles