CORE DATA objectId changes constantly

前端 未结 2 942
面向向阳花
面向向阳花 2021-01-03 10:37

I have some data that I export into an XML file and put in a remote FTP Server.

I have to identified each object with a unique attribute, it doesn\'t matter wich is,

相关标签:
2条回答
  • 2021-01-03 11:04

    I think this maybe a reporting problem. The numbers you show that are supposed to be a URI/UUID are way, way to 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. A UUID is made unique over both space and time by combining a value unique to the computer on which it was generated—usually the Ethernet hardware address—and a value representing the number of 100-nanosecond intervals since October 15, 1582 at 00:00:00.

    The standard format for UUIDs represented in ASCII is a string punctuated by hyphens, for example 68753A44-4D6F-1226-9C60-0050E4C00067. The hex representation looks, as you might expect, like a list of numerical 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 simply create it and then copy the resulting strings into your header and C language source files. Because a UUID is expressed simply as an array of bytes, there are no endianness considerations for different platforms.

    I think you're seeing different values because your only getting a piece, and a different piece at that, each time you check the UUID. Represented as a URI, they should look more like a URL. They definitely won't look like an integer.

    0 讨论(0)
  • 2021-01-03 11:06

    The NSManagedObjectID is not guaranteed to be consistent. It can change based 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 the NSManagedObjectID is when you need to pass references between threads. Other than that situation you should not rely upon it for anything.

    If you need a unique id then create one and store it in your entities.

    0 讨论(0)
提交回复
热议问题