How to uniquely identify an nsmanged object with a string?

I use basic data and monitoring the region. The only way to distinguish between controlled regions is through an NSString for an identifier. I would like to use NSManagedObjectID, but I cannot get it to work.

What I tried:

NSURL *objURL = [managedObjectID URIRepresentation];
NSError *err;
NSString *identifier = [NSString stringWithContentsOfURL:myURL
                                                encoding:NSASCIIStringEncoding
                                                   error:&err];

I get an error:

The operation couldn’t be completed. (Cocoa error 256.)

Any ideas on a better way? Or what am I doing wrong?

+3
source share
1 answer

URI NSManagedObjectID. stringWithContentsOfURL:encoding:error: , URI; , URI http file .. , URI NSManagedObjectID, , .

,

 NSString*identifier=[objURL absoluteString];

URL-.

, :

, objectID , . , .

+9

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


All Articles