问题
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.
来源:https://stackoverflow.com/questions/8469093/updating-the-matchdata-in-a-gkturnbasedmatch-without-ending-the-turn