swiftnsuuid

How to convert String to NSUUID in Swift?


I am developing iOS Swift.

I have convert the NSUUID to String like the following:

var bdAddr: NSUUID?
var text: String = bdAddr!.UUIDString

But how to convert String to NSUUID in Swift?


Solution

  • If you look at Apple's NSUUID documentation You'll see a method -initWithUUIDString: that initializes the NSUUID object with the string representation of a UUID.