Last active
April 15, 2019 17:16
-
-
Save brokaw/bbdc5708f65bc0f7974aaaf2cb9dd71c to your computer and use it in GitHub Desktop.
Extension on CBUUID to return a UUID
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension CBUUID { | |
var UUIDValue: UUID? { | |
get { | |
return self.data.withUnsafeBytes { buffer in | |
guard buffer.count == MemoryLayout<uuid_t>.size else { return nil } | |
let uuid = buffer.bindMemory(to: uuid_t.self) | |
return UUID(uuid: uuid.baseAddress!.pointee) | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment