Continuing a Game in Progress

When you resume a game on your next turn, assuming it is not the first turn of a match, you will need to first restore the game state to its current position. To do this, we begin by modifying our viewDidLoad method to get the current match data. We need to call loadMatchDataWithCompletionHandler on our match object. This returns the data that we sent to the next player in the previous method. We then convert the NSData back into a dictionary and then add it to our gameDictionary.

- (void)viewDidLoad {     //Existing viewDidLoad code...     [self.match loadMatchDataWithCompletionHandler:^(NSData *matchData, NSError *error) {         NSDictionary *myDict = [NSPropertyListSerialization propertyListFromData:match.matchData ...

Get Beginning iOS Game Center and Game Kit: For iPhone, iPad, and iPod touch now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.