Hi Rick,

> On 26. Jun 2017, at 02:37, Rick Mann via swift-users <swift-users@swift.org> 
> wrote:

[snip]

> I'd also like to avoid unnecessary copying of the data. All of it is 
> immutable for the purposes of this problem.
> 
> How can I get the UInt16 that starts at byte X in a Data? Same goes for 
> Double or Int32 or whatever.

I’m not sure what Swift’s stance on this is, but not all platforms allow 
misaligned memory accesses (such as your attempt to access a UInt16 that lies 
at an odd memory address).

So at least IMO, copying and assembling the bytes into an instance of the 
actual destination type seems to be exactly the right thing to do.

        Daniel.

_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users

Reply via email to