UUID in Swift iOS 8.1

I have a problem when I try to change my app to iOS 8.1. The syntax for creating the doesent UUID is larger:

var uuid = NSUUID.UUID().UUIDString

      

How to create a uuid in iOS 8.1 using Swift?

+3


source to share


2 answers


Swift 3:

var uuid = NSUUID().uuidString
print("UUID string: \(uuid)") // UUID string: D7C7F26B-608A-465A-ADF8-4F5365513E5D

      



Swift 2:

var uuid = NSUUID().UUIDString
println("UUID string: \(uuid)") // UUID string: 76A4073A-D79C-45FD-A5D6-86E52AD8C771

      

+7


source


For Swift 3, you can do the following:



UUID().uuidString

      

+2


source







All Articles