It seems that GameKit only allows GKTurnBasedMatch
to be updated once per time that GKTurnBasedMatch
is loaded from the Game Center servers. Is there an other way to update the matchData
property?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
The following method was added to GKTurnBasedMatch in iOS 6.0 and will do what you need:
- (void)saveCurrentTurnWithMatchData:(NSData *)matchData
completionHandler:(void (^)(NSError *error))completionHandler
"Update the match data without advancing the game to another player"
回答2:
You can call `-
[GKTurnBasedMatch (void)loadMatchDataWithCompletionHandler:(void (^)(NSData *matchData, NSError *error))completionHandler];
as often as you like to get updated matchData. If you want to do incremental moves you also can do -
[GKTunrBasedMatch - (void)endTurnWithNextParticipant:(GKTurnBasedParticipant *)nextParticipant matchData:(NSData *)matchData completionHandler:(void (^)(NSError *error))completionHandler];
with your own participant as next participant. However, you have to loadMatchDataWithCompletionhandler: once again after you submitted your partial move before you are allowed to submit the next move part.