ios - Extract struct from NSData in Swift -
I am creating a sports center game and I send a data packet containing a This works like Objective-C, But I don do not understand how to decode on Assume that you do this by struct MovePacket / P>
var packet = movepacket (packetID: 1, move: myMove) Data Pack = NSDTA (bytes)
NSData back to my
struct MovePacket . This is one of my efforts:
Funk match (match: GKMach !!, Rescindia Data: NSDTa !, Remote Player Player: GCplayer!) {Var Packet: Hall Packet Data.Tite (And packet, length: sizeof (MovePacket)) // Here is an error: Before it is being started println (packet) // variable 'packet' used before starting 'packet' The address of
NSData . ????:
Joy match (match: GK match !, Reservativa data: NSDTa !, Remote Player player: GCplayer!) {If data. Lifetime == Size (move packet ) {Packet = unsecure pointer & lieutenant; Leve packet & gt; (Data.bite) .memory println (packet)} other {// error: the data size is incorrect}}
Comments
Post a Comment