迁移到 Swift 5 后 SQLite.swift 出现问题
Problem with SQLite.swift after migration to Swift 5
我使用 SQLite.swift 并在升级到 Swift 5 后库中出现错误。请帮我重写方法。
错误:
'withUnsafeBytes' is deprecated: use `withUnsafeBytes<R>(_: (UnsafeRawBufferPointer) throws -> R) rethrows -> R` instead
代码:
public var datatypeValue: Blob {
return withUnsafeBytes { (pointer: UnsafePointer<UInt8>) -> Blob in
return Blob(bytes: pointer, length: count)
}
}
Till SQLite.swift
没有发布任何带有修复的更新,您可以尝试手动修改 SQLite/Foundation.swift
for fromDatatypeValue(_ dataValue: Blob)
函数和计算的 属性 datatypeValue
这样:
public static func fromDatatypeValue(_ dataValue: Blob) -> Data {
return Data(dataValue.bytes)
}
public var datatypeValue: Blob {
return withUnsafeBytes { (pointer: UnsafeRawBufferPointer) -> Blob in
return Blob(bytes: pointer.baseAddress!, length: count)
}
}
我使用 SQLite.swift 并在升级到 Swift 5 后库中出现错误。请帮我重写方法。
错误:
'withUnsafeBytes' is deprecated: use `withUnsafeBytes<R>(_: (UnsafeRawBufferPointer) throws -> R) rethrows -> R` instead
代码:
public var datatypeValue: Blob {
return withUnsafeBytes { (pointer: UnsafePointer<UInt8>) -> Blob in
return Blob(bytes: pointer, length: count)
}
}
Till SQLite.swift
没有发布任何带有修复的更新,您可以尝试手动修改 SQLite/Foundation.swift
for fromDatatypeValue(_ dataValue: Blob)
函数和计算的 属性 datatypeValue
这样:
public static func fromDatatypeValue(_ dataValue: Blob) -> Data {
return Data(dataValue.bytes)
}
public var datatypeValue: Blob {
return withUnsafeBytes { (pointer: UnsafeRawBufferPointer) -> Blob in
return Blob(bytes: pointer.baseAddress!, length: count)
}
}