Extract struct from NSData in Swift
问题 I'm making Game Center game. I send a data packet containing a struct MovePacket like this: var packet = MovePacket(packetID: 1, move: myMove) let dataPacket = NSData(bytes: &packet, length: sizeof(MovePacket)) currentMatch!.sendDataToAllPlayers(dataPacket, withDataMode: GKMatchSendDataMode.Reliable, error: nil) This works like in Objective-C, but I don't understand how to decode the received NSData back to my struct MovePacket . This is one of my tries: func match(match: GKMatch!,