Reputation: 336
What is the Swift equivalent of this objective-C code snippet:
[CBUUID UUIDWithString: @"9abd"]
I tried:
let uuid = UUID(uuidString: "9abd") // this is nil
let cbuuid = CBUUID(nsuuid: uuid!)
But the UUID
is nil.
Thanks!
Upvotes: 0
Views: 208
Reputation: 8911
Because of creating an UUID need a valid string like 7AFD7082-7A14-44F8-B839-5C4D98842798
According to Apple's document:
Parameters
The source string containing the UUID. The standard format for UUIDs represented in ASCII is a string punctuated by hyphens, for example 68753A44-4D6F-1226-9C60-0050E4C00067.
Return Value
A new UUID object. Returns nil for invalid strings.
Upvotes: 1