开发者

How can I send a NSDictionary/NSArray with the GameKit?

开发者 https://www.devze.com 2023-02-03 09:39 出处:网络
I hear i should convert the dict to a propertylist and then send it and convert it back. Or is there a better way?

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

精彩评论

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