Skip to content

Instantly share code, notes, and snippets.

@ashtonmeuser
Created November 6, 2017 21:56
Show Gist options
  • Select an option

  • Save ashtonmeuser/811cea5ccda20d820755774ab4e1fd9c to your computer and use it in GitHub Desktop.

Select an option

Save ashtonmeuser/811cea5ccda20d820755774ab4e1fd9c to your computer and use it in GitHub Desktop.
Creates a UUID version 1 string
//
// 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