CORE DATAId is constantly changing

I have some data that I am exporting to an XML file and putting it on a remote FTP server.

I have to identify each object with a unique attribute, it doesn't matter which it should be, but it should be constant always => it can never change.

I don't want to create a unique attribute, sequence, serial number, etc.

I use objectID, but every time I use it, I get a new link.

I know that before the object was saved it has a "temporary id", but after saving it, it gets the final result.

I don't see it, never.

When I export, I just get all the data and the loop, and I always get a new link:

NSURL *objectID = [[personalDataObject objectID] URIRepresentation];

// some of id received for the SAME OBJECT (no changes made, saved, ...)
// 61993296
// 62194624

      

thanks,

g.

change

I used% d instead of% @, now the returned data is:

x-coredata://F46F3300-8FED-4876-B0BF-E4D2A9D80913/DataEntered/p1
x-coredata://F46F3300-8FED-4876-B0BF-E4D2A9D80913/DataEntered/p2

      

+2


a source to share


2 answers


I think it might be a reporting issue. The numbers you show, which are supposed to be URI / UUID, are in a way that can be kept short.

They should look like :



UUIDs (Universally Unique Identifiers), also known as GUIDs (Globally Unique Identifiers) or IIDs (Interface Identifiers), are 128-bit values ​​guaranteed to be unique. The UUID is unique in both space and time, combining a value unique to the computer on which it was generated - usually an Ethernet hardware address - and a value representing the number of 100-nanosecond intervals from October 15, 1582 at 00:00:00.

The standard format for UUIDs represented in ASCII is a string for example, hyphens 68753A44-4D6F-1226-9C60-0050E4C00067. The hexadecimal representation is presented as you might expect, as is the list of numeric values ​​preceded by 0x. For example, 0xD7, 0x36, 0x95, 0x0A, 0x4D, 0x6E, 0x12, 0x26, 0x80, 0x3A, 0x00, 0x50, 0xE4, 0xC0, 0x00, 0x67. To use a UUID, you just create it and then copy the resulting lines into your header and C language source files. Since the UUID is expressed simply as an array of bytes, there is no judgment on different platforms.

I think you are seeing different values ​​because you only get a chunk and a different thing every time you check the UUID. Provided as URIs, they should look more like URLs. They definitely won't look like a whole.

+3


a source


Not supported NSManagedObjectID

. It can change depending on a number of factors, including data migration and other factors. If you are using this as a unique identifier for your objects, stop.

The only time you want to use NSManagedObjectID

is when you need to pass links between threads. Apart from this situation, you should not rely on it for anything.



If you need a unique identifier, create it and store it in your entities.

+16


a source







All Articles