应用程序在Game Center Challenge Friends发送后崩溃

时间:2015-12-18 15:05:43

标签: ios arrays swift casting game-center

我一直在使用DaRkDOGs Easy Game Center代码(非常有用!)并添加了一个额外的类(如下所示)来发送“挑战朋友”请求。

public class func challengeFriendRequest(leaderboard: String, scoreValue : Int64, players: [GKPlayer]) {

    guard EGC.isPlayerIdentified else {
        EGCError.NotLogin.errorCall()
        return
    }

    guard EGC.isConnectedToNetwork else {
        EGCError.NoConnection.errorCall()
        return
    }

    do {
        let message : String? = "Try and beat this!"
        let score = GKScore(leaderboardIdentifier: leaderboard)
        score.value = scoreValue

        let delegatVC = try EGC.sharedInstance.getDelegate()
        var delegateParent:UIViewController? = delegatVC.parentViewController
        if delegateParent == nil {
            delegateParent = delegatVC
        }

        let controllerGKChallenge = score.challengeComposeControllerWithMessage(message, players: players, completionHandler: { (challengeVC, didChallenge, playersChallenged) -> Void in

            if didChallenge {
                print("\(playersChallenged!.count) players challenged")
            }
            delegateParent!.dismissViewControllerAnimated(true, completion: nil)
        })

            delegateParent!.presentViewController(controllerGKChallenge, animated: true, completion: nil)

    } catch EGCError.NoDelegate {
        EGCError.NoDelegate.errorCall()

    } catch {
        fatalError("Dont work\(error)")
    }
}

游戏中心“挑战朋友”弹出窗口显示填充了正确的朋友和消息。我可以取消呼叫并控制返回应用程序。但是,如果我发送挑战,应用程序崩溃时会出现以下错误:

  

thread 1 exc_breakpoint(code = exc_arm_breakpoint,subcode = 0xe7ffdefe)。

在堆栈顶部,错误表明阵列强制转换问题:

  

“0_arrayForceCast A,B>([A]) - > [B]”。

我认为这可能与调用调用中使用的GKPlayers数组有关,但我无法解决问题所在。

任何正确方向的指针都会很棒。

我正在测试我的应用程序在IOS 9.1部署目标上的IPad 2和iPhone 5s。

0 个答案:

没有答案
相关问题