From df8887be050cfcc7492ae753b22c957548dfb386 Mon Sep 17 00:00:00 2001 From: Florent Pillet Date: Sun, 20 May 2018 00:27:02 +0200 Subject: [PATCH] Fix NSUUID compilation issue (now using more Swift code) --- GRDB/Core/Support/Foundation/UUID.swift | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/GRDB/Core/Support/Foundation/UUID.swift b/GRDB/Core/Support/Foundation/UUID.swift index 78a9062dd..15dd51e6f 100644 --- a/GRDB/Core/Support/Foundation/UUID.swift +++ b/GRDB/Core/Support/Foundation/UUID.swift @@ -9,16 +9,18 @@ extension NSUUID : DatabaseValueConvertible { var uuidBytes = ContiguousArray(repeating: UInt8(0), count: 16) return uuidBytes.withUnsafeMutableBufferPointer { buffer in getBytes(buffer.baseAddress!) - return Data(bytes: buffer.baseAddress, length: 16).databaseValue + return Data(buffer: buffer).databaseValue } } /// Returns an NSUUID initialized from *dbValue*, if possible. public static func fromDatabaseValue(_ dbValue: DatabaseValue) -> Self? { - guard let data = Data.fromDatabaseValue(dbValue), data.length == 16 else { + guard let data = Data.fromDatabaseValue(dbValue), data.count == 16 else { return nil } - return self.init(uuidBytes: data.bytes.assumingMemoryBound(to: UInt8.self)) + return data.withUnsafeBytes { buffer in + self.init(uuidBytes: buffer) + } } } #endif