SwiftCBOR
SwiftCBOR copied to clipboard
iOS 16.1 UnsafeRawPointer is depreciated and decodeItem returns nil value
UnsafeRawPointer is depreciated:
note: use the 'withUnsafeBytes' method on Array in order to explicitly convert argument to buffer pointer valid for a defined scope
and on iOS 16.1 devices readUInt returns incorrect value
private func readUInt<T: UnsignedInteger>(_ n: Int) throws -> T {
return UnsafeRawPointer(Array(try istream.popBytes(n).reversed())).load(as: T.self)
}
Solution: It could be potentially refactored by:
private func readUInt<T: UnsignedInteger>(_ n: Int) throws -> T {
let array = Array(try istream.popBytes(n).reversed())
return array.withUnsafeBytes { $0.load(as: T.self) }
}
Notice:
Probably all UnsafeRawPointer( occurrence should be replaced by .withUnsafeBytes method call
Hm.. is it possible that https://cocoapods.org/pods/CBOR is not up to date ?
Issue probably can be rejected.
https://cocoapods.org/pods/CBOR
and
https://cocoapods.org/pods/SwiftCBOR
have the same link to GitHub repository, but I don't see any information that CBOR pods is depreciated and renamed into SwiftCBOR
I'm not sure about the renaming but I don't see any current usage of UnsafeRawPointer in the current codebase, so I'm going to close the issue 👍