Reputation: 1405
The following piece of code takes a given NSData
and "fills" it into a struct of type Container.
data: NSData ....
var tempBuffer: Container? = nil
data.getBytes(&tempBuffer, length: MemoryLayout<Container>.size)
How do I formulate this using Data
instead of NSData
? I simply do not understand how to formulate it in Swift. I guess you need withUnsafeBytes
...
Thanks Chris
Upvotes: 0
Views: 197
Reputation: 58029
Since Data
is convertible to NSData
, you can use as
:
let nsData = data as NSData
Upvotes: 0