In my application, I have a dictionary called matchDataDictionary and I set the following:
[[GCTurnBasedMatchHelper sharedInstance].matchDataDictionary setObject:deck forKey:@"deck"];
where deck is an instance of Deck: https://gist.github.com/naderhen/4711899
I then am trying to just test the archiving/unarchiving with the following:
Archiving (this seems to work):
NSMutableData *newData = [[NSMutableData alloc] init];
NSKeyedArchiver *archiver = [[NSKeyedArchiver alloc] initForWritingWithMutableData:newData];
[archiver encodeObject:[GCTurnBasedMatchHelper sharedInstance].matchDataDictionary forKey:@"root"];
[archiver finishEncoding];
NSLog(@"Archived Data: %@", newData);
Unarchiving (Doesn't Work):
NSKeyedUnarchiver *unarchiver = [[NSKeyedUnarchiver alloc] initForReadingWithData:newData];
NSMutableDictionary *matchDataDictionary = [unarchiver decodeObjectForKey:@"root"];
[unarchiver finishDecoding];
NSLog(@"Unarchived Data: %@", matchDataDictionary);
Any guidance as to how I can go about effectively archiving and subsequently unarchiving this data would be greatly appreciated. If it helps, this is for a turn-based game using the GameKit framework, so I'm trying to prepare user actions to send via the current match's matchData.
Also! Any advice on how I might fix up the Deck encoding to include its "Tiles" array would be greatly appreciated.
Thanks so much!
Nader