开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜