How can I send a NSDictionary/NSArray with the GameKit?
I hear i should convert the dict to a propertylist and then send it and convert it back. Or is there a better way?
Anyway can someone show the code for the best solution?? Please don't post only the methods. I need a开发者_Go百科 bit of code.
Thank you very much :)
To get NSData
from a NSDictionary
or NSArray
. Use NSKeyedArchiver
like this
NSData *data = [NSKeyedArchiver archivedDataWithRootObject:yourDictionary];
Then back to NSDictionary
or NSArray
:
NSDictionary *dict = [NSKeyedUnarchiver unarchiveObjectWithData:data];
You might find useful to read Apple's guide to archives and serialization.
精彩评论