[swift-users] Swift 3 and bytes

Gerriet M. Denkmann g at mdenkmann.de
Sun Sep 25 06:28:30 CDT 2016


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



More information about the swift-users mailing list