zacjordaan zacjordaan - 2 years ago 142
Swift Question

Generate a UUID on iOS from Swift

In my iOS Swift app I want to generate random UUID (GUID) strings for use as a table key, and this snippet appears to work:

let uuid = CFUUIDCreateString(nil, CFUUIDCreate(nil))

Is this safe?

Or is there perhaps a better (recommended) approach?

Answer Source

Try this one:

var uuid = NSUUID().UUIDString
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download