I've managed to fix most of the errors I've received when converting from 1.2 -> 2.0. Most of the time I just added an ! or ? and was able to make most error notifications go away. I have a few issues remaining that I cannot find a way around:
**#1 - My browser glitched when I wrapped this in code format**
playerDict = NSDictionary(objects: [GameKitHelper.sharedGameKitHelper.localPlayer.playerID, NSInteger(ourRandomNumber)], forKeys: [playerIdKey, randomNumberKey])
Error: "Ambiguous reference to member 'Int.Init'
This error is coming up from where it says "NSInteger(ourRandomNumber)"... Not really sure how to fix that.
**#2**
GKPlayer.loadPlayersForIdentifiers(idsArray as [AnyObject], withCompletionHandler: { (players, error) -> Void in
Error: Cannot convert value of type [AnyObject] to expected argument type [String].
Here I've tried adding ? and ! to 'as' as well as changed the value of AnyObject to 'String' and I still get error: NSMutableArray is not convertible to string
**#3**
This one is just a notice and not a compiler error
if(match != nil){
for players in match!.players{
if let player = players as? GKPlayer{
idsArray.addObject(player.playerID!)
}
}
}
Here I am getting a notice: 'Conditional cast from GKPlayer to GKPlayer always succeeds'... Do I even need to fix this? I feel like I can get away with the whole if let statement and simple replace it with this
idsArray.addObject(players.playerID!)
That should work, but I'd like someone to confirm with me.
Sorry, I cannot reproduce your issue, if your provided data types are correct:
playerID is a string and ourRandomNumber is an Int
I assumed the type of playerID as `String?`, although you described it as `string`.
So, you want another guess game, let's try. Assuming ourRandomNumber is Int32, and I get the same error message:
error: type of expression is ambiguous without more context
Without correct info provided, you cannot get a correct correction.
Try changing `ourRandomNumber` in the line to `Int(ourRandomNumber)`.