简体   繁体   中英

What data type should I use to store a GUID in Core Data?

I'm going to be generating CFUUID objects (if there's a better way to create a GUID on iOS, let me know) that need to be persisted using Core Data. There is no GUID data type in Core Data. What's the preferred type? It looks like CFUUID objects easily convert to and from a string, so I'm thinking that. Another option might be Binary Data.

Another consideration is that these GUIDs will going into and coming out of JSON objects (using built-in iOS5 JSON Serialization via NSJSONSerialization).

If I were doing it, I would just store it as a string.

You could store it as binary data, but since it's going to be going into and coming out of a string (which is what JSON is represented with) it's probably easier to store it as a string and not worry about converting it backwards and forwards.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM