gerriet
(Gerriet M. Denkmann)
1
Got:
var bitField : UnsafeMutablePointer<UInt32>
bitField = UnsafeMutablePointer< UInt32 >.allocate(capacity: 912)
But now I want to read a certain range as bytes (not as UInt32);
let staP = bitField + 23
let endP = bitField + 99
let staB = UnsafeMutablePointer<UInt8>(staP) ← this does not work in Swift 3
let endB = UnsafeMutablePointer<UInt8>(endP)
let result = someFunction( from: staB, until: endB ) // does something for bytes staB ..< endB
Xcode hints about “withMemoryRebound”, but I cannot figure out the correct syntax.
Gerriet
Jens
2
Use UnsafeMutableRawPointer.
···
On Sun, Sep 25, 2016 at 1:28 PM, Gerriet M. Denkmann via swift-users < swift-users@swift.org> wrote:
Got:
var bitField : UnsafeMutablePointer<UInt32>
bitField = UnsafeMutablePointer< UInt32 >.allocate(capacity: 912)
But now I want to read a certain range as bytes (not as UInt32);
let staP = bitField + 23
let endP = bitField + 99
let staB = UnsafeMutablePointer<UInt8>(staP) ← this does not work in
Swift 3
let endB = UnsafeMutablePointer<UInt8>(endP)
let result = someFunction( from: staB, until: endB ) // does something for
bytes staB ..< endB
Xcode hints about “withMemoryRebound”, but I cannot figure out the correct
syntax.
Gerriet
_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users