J.D. J.D. - 14 days ago 6
Swift Question

Best way to create a primary key - Swift

I am trying to build a project with ore data.
I want to build an ID for each entity, but I am not sure whats the best way to do it.
Now this ID would be that entity primary key (unique, not nil and mandatory).
Any tips please?

Note that I need this ID, once it exists, to be always the same.
I read somewhere that objectID "is temporary until either the object is saved for the first time or you call"...

Answer

If I'm not mistaking, what are you looking for is NSUUID().uuidString. For more information, check the official documentation.