按照該文檔中,我使用:遊戲中心多人代碼
- (void) match:(GKMatch*) match player:(NSString*) playerID didChangeState:(GKPlayerConnectionState) state;
來進行最初的遊戲協商。我這樣做的能力範圍:
if (matchStarted_ == NO && [match expectedPlayerCount] == 0) { ... }
我需要決定哪些設備是負責建立遊戲。我通過排序match.playerIDs
NSArray的實例和[GKLocalPlayer localPlayer].playerID
的NSString在排序後的數組的索引0比較到playerID的NSString做到這一點。該玩家創建遊戲,並將數據發送給所有玩家。
然而,甚至爲0的expectedPlayerCount,該playerIDs陣列在這一點上的零項,給我一個數組溢出。這是爲什麼?我該怎麼做才能做出明確的選擇來生成遊戲?