ios - Extract struct from NSData in Swift -


I am creating a sports center game and I send a data packet containing a struct MovePacket / P>

  var packet = movepacket (packetID: 1, move: myMove) Data Pack = NSDTA (bytes)   

This works like Objective-C, But I don do not understand how to decode on 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    

Assume that you do this by 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

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -