Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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).

like image 946
Greg Smalter Avatar asked Apr 27 '12 13:04

Greg Smalter


1 Answers

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.

like image 93
Abizern Avatar answered Sep 22 '22 12:09

Abizern