round trip Swift number types to/from Data

后端 未结 3 1384
借酒劲吻你
借酒劲吻你 2020-11-22 04:23

With Swift 3 leaning towards Data instead of [UInt8], I\'m trying to ferret out what the most efficient/idiomatic way to encode/decode swifts vario

3条回答
  •  南方客
    南方客 (楼主)
    2020-11-22 04:43

    You can get an unsafe pointer to mutable objects by using withUnsafePointer:

    withUnsafePointer(&input) { /* $0 is your pointer */ }
    

    I don't know of a way to get one for immutable objects, because the inout operator only works on mutable objects.

    This is demonstrated in the answer that you've linked to.

提交回复
热议问题