Created
November 6, 2017 21:56
-
-
Save ashtonmeuser/811cea5ccda20d820755774ab4e1fd9c to your computer and use it in GitHub Desktop.
Creates a UUID version 1 string
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
| // | |
| // UUIDv1.swift | |
| // | |
| // Created by Ashton Meuser on 2017-07-04. | |
| // Copyright © 2017 Ashton Meuser. All rights reserved. | |
| // | |
| import Foundation | |
| extension UUID { | |
| // Returns UUID version 1 | |
| static func v1() -> UUID { | |
| var uuid: uuid_t = (0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0) | |
| withUnsafeMutablePointer(to: &uuid) { | |
| $0.withMemoryRebound(to: UInt8.self, capacity: 16) { | |
| uuid_generate_time($0) | |
| } | |
| } | |
| return UUID(uuid: uuid) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment