Possible duplicate:Send and receive NSData via GameKit
I have a structure that consists of int variable and 2 float pointers (arrays). How can I pack this ib NSData structure and then unpack it?
You can pack the structure using the dataWithBytes pf NSData method:
struct aStruct { /* Implementation */ }; //Struct variable aStruct exampleStruct; // pack the struct into an NSData Object NSData *myData = [NSData dataWithBytes:&exampleStruct length:sizeof(exampleStruct)]; // get back the the struct from the object [myData getBytes:&exampleStruct length:sizeof(exampleStruct)];