Skip to content

Instantly share code, notes, and snippets.

@brokaw
Last active April 15, 2019 17:16
Show Gist options
  • Save brokaw/bbdc5708f65bc0f7974aaaf2cb9dd71c to your computer and use it in GitHub Desktop.
Save brokaw/bbdc5708f65bc0f7974aaaf2cb9dd71c to your computer and use it in GitHub Desktop.
Extension on CBUUID to return a UUID
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