chooseBestHostPlayerWithCompletionHandler返回null

jye*_*yek 3 cocos2d-iphone game-center ios6

以下代码将最佳主机返回为null.我怎样才能让它发挥作用?

[gameKitHelper.match chooseBestHostPlayerWithCompletionHandler: ^(NSString *playerID) {
    gameKitHelper.hostingPlayer = [playerID retain];
    NSLog(@"Best host = %@",gameKitHelper.hostingPlayer);
}];
Run Code Online (Sandbox Code Playgroud)

Guj*_*min 5

我发现一个简单的解决方案(而不是生成一个需要额外协商和数据传输的随机数)是简单地将[[GKLocalPlayer localPlayer] playerID]与匹配中的playerID进行比较,并选择第一个按升序排序.这可以在所有设备上完成,保证作为主机的唯一播放器ID,并保证在所有设备上选择相同的唯一播放器ID.