2015-10-02 30 views
1

後,這是我的代碼:遊戲中心不接受我的代碼更新到斯威夫特2

if GKLocalPlayer.localPlayer().authenticated { 
      if mode == 60 { 
       var scoreReporter2 = GKScore(leaderboardIdentifier: "countrymaster60") //leaderboard id here 

       scoreReporter2.value = Int64(score) //score variable here (same as above) 
       var scoreArray: [GKScore] = [scoreReporter2] 
       GKScore.reportScores(scoreArray, withCompletionHandler: {(error : NSError!) -> Void in 
        if error != nil { 
         print("error") 
        } 

的錯誤消息,則給:

不能援引「reportScores」與參數列表([GKScore],withCompletionHandler :(NSError!) - > Void)'

有什麼建議嗎?

回答

1

文檔說,該方法的簽名是:

class func reportScores(_ scores: [GKScore], withCompletionHandler completionHandler: ((NSError?) -> Void)?) 

所以,你需要在完成處理器的可選的error變量。

變化

GKScore.reportScores(scoreArray, withCompletionHandler: {(error : NSError!) -> Void in 

GKScore.reportScores(scoreArray, withCompletionHandler: {(error : NSError?) -> Void in