Skip to content

Instantly share code, notes, and snippets.

@chuganzy
Last active September 7, 2015 06:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chuganzy/85743eee8609a80dd35a to your computer and use it in GitHub Desktop.
Save chuganzy/85743eee8609a80dd35a to your computer and use it in GitHub Desktop.
uuid_generate_time in Swift
extension NSUUID {
class func timeBasedUUID() -> NSUUID {
let uuidSize = sizeof(uuid_t)
let uuidPointer = UnsafeMutablePointer<UInt8>.alloc(uuidSize)
uuid_generate_time(uuidPointer)
let uuid = NSUUID(UUIDBytes: uuidPointer)
uuidPointer.dealloc(uuidSize)
return uuid
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment