我正在尝试使用 Xcode 7 beta 5 编写一个简单的多人 Swift 程序。我在运行时遇到以下错误:
[__NSPlaceholderArray initWithObjects:count:]: attempt to insert nil object from objects[0]'
*** First throw call stack
然后我试错了,发现这段代码不知何故引入了这个错误:
func setupMatchHandler() {
/* This function handles invite as sent by other users */
GKMatchmaker.sharedMatchmaker().matchForInvite(GKInvite().self , completionHandler: { (invitedMatch , invitationError) -> Void in
if invitationError != nil {
// error out
print("Game Center error: \(invitationError)")
}
if invitedMatch != nil {
// success
print("invitation received!")
}
})
}
我想知道这里的任何专家都可以阐明这里出了什么问题吗?一百万!
山姆
最佳答案
也许检查 (GKInvite().self != nil)
会有帮助?
看来您唯一通过 matchForInvite 插入的就是这个
关于xcode - 遇到运行时错误 "attempt to insert nil object ",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32155120/