@@ -12,7 +12,7 @@ import GRDBSQLite
1212
1313import Foundation
1414
15- #if !os(Linux) && !os( Windows)
15+ #if !os(Windows)
1616/// NSUUID adopts DatabaseValueConvertible
1717extension NSUUID : DatabaseValueConvertible {
1818 /// Returns a BLOB database value containing the uuid bytes.
@@ -36,10 +36,17 @@ extension NSUUID: DatabaseValueConvertible {
3636 switch dbValue. storage {
3737 case . blob( let data) where data. count == 16 :
3838 return data. withUnsafeBytes {
39- self . init ( uuidBytes: $0. bindMemory ( to: UInt8 . self) . baseAddress)
39+ #if canImport(Darwin)
40+ self . init ( uuidBytes: $0. bindMemory ( to: UInt8 . self) . baseAddress)
41+ #else
42+ guard let uuidBytes = $0. bindMemory ( to: UInt8 . self) . baseAddress else {
43+ return nil as Self ?
44+ }
45+ return NSUUID ( uuidBytes: uuidBytes) as? Self
46+ #endif
4047 }
4148 case . string( let string) :
42- return self . init ( uuidString: string)
49+ return NSUUID ( uuidString: string) as? Self
4350 default :
4451 return nil
4552 }
@@ -91,8 +98,8 @@ extension UUID: StatementColumnConvertible {
9198 self . init ( uuid: uuid. uuid)
9299 case SQLITE_BLOB:
93100 guard sqlite3_column_bytes ( sqliteStatement, index) == 16 ,
94- let blob = sqlite3_column_blob ( sqliteStatement, index) else
95- {
101+ let blob = sqlite3_column_blob ( sqliteStatement, index)
102+ else {
96103 return nil
97104 }
98105 self . init ( uuid: blob. assumingMemoryBound ( to: uuid_t. self) . pointee)
0 commit comments