The following code returns best host as null. How can I get it to work?
[gameKitHelper.match chooseBestHostPlayerWithCompletionHandler: ^(NSString *playerID) {
gameKitHelper.hostingPlayer = [playerID retain];
NSLog(@"Best host = %@",gameKitHelper.hostingPlayer);
}];
I found a simple solution (instead of generating a random number which requires additional negotiation and data transfer) is to simply compare [[GKLocalPlayer localPlayer] playerID] with the playerIDs in the match and choose the first one ordered ascending. This can be done on all the devices, guarantees a unique playerID as host and guarantees the same unique playerID is chosen on all devices.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With