Generate a UUID on iOS from Swift
You could also just use the NSUUID API:
let uuid = NSUUID()
If you want to get the string value back out, you can use uuid.UUIDString
.
Note that NSUUID
is available from iOS 6 and up.
For Swift 4;
let uuid = NSUUID().uuidString.lowercased()
Try this one:
let uuid = NSUUID().uuidString
print(uuid)
Swift 3/4/5
let uuid = UUID().uuidString
print(uuid)