-
Notifications
You must be signed in to change notification settings - Fork 214
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Library compile error on Data.swift #295
Comments
For First issue replace return subdata(in: offset ..< offset + length).withUnsafeBytes {
$0.baseAddress!.bindMemory(to: R.self, capacity: 1).pointee
} with #if swift(>=5.0)
return subdata(in: offset ..< offset + length).withUnsafeBytes { $0.load(as: T.self) }
#else
return subdata(in: offset ..< offset + length).withUnsafeBytes { $0.pointee }
#endif For Second issue solution is: var hexString: String {
var array: [UInt8] = []
self.withUnsafeBytes {
array.append(contentsOf: getByteArray(pointer: $0))
}
return array.reduce("") { (result, byte) -> String in
result + String(format: "%02x", byte)
}
}
private func getByteArray(pointer: UnsafePointer<UInt8>) -> [UInt8] {
let buffer = UnsafeBufferPointer<UInt8>(start: pointer, count: count)
return [UInt8](buffer)
} |
I will fix it in 4.4.2. @KeerthiChinivar thanks for your reply! |
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm trying to test the library but I'm facing a compile error on file Data.swift
Line 36:
$0.baseAddress!.bindMemory(to: R.self, capacity: 1).pointee
Error: /Users/luciomacellari/Projects/dfuDemo/Pods/iOSDFULibrary/iOSDFULibrary/Classes/Utilities/Data.swift:36:13: Value of type 'UnsafePointer<_>' has no member 'baseAddress'
Line 50:
array.append(contentsOf: $0)
Error:
/Users/luciomacellari/Projects/dfuDemo/Pods/iOSDFULibrary/iOSDFULibrary/Classes/Utilities/Data.swift:50:25: Extraneous argument label 'contentsOf:' in call
I'm compiling with Xcode 10.1
The text was updated successfully, but these errors were encountered: