简体   繁体   English

如何使用 GameKit 将默认值设为 0

[英]How do I make the default value 0 with GameKit

let localPlayerScore = request.localPlayerScore ?? 0

The problem is that Swift is expecting the 0 to be of type GKScore .问题是 Swift 期望 0 是GKScore类型。

I get the following error:我收到以下错误:

Cannot convert value of type 'Int' to expected argument type 'GKScore'无法将“Int”类型的值转换为预期的参数类型“GKScore”

let localPlayerScore = request.localPlayerScore.value?? 0

GKScore GK评分

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使我的浏览器应用程序成为 Swift 中的默认应用程序? - How do I make my browser application the default application in Swift? 如何在SQLite.swift中使列DEFAULT(NULL) - How do I make a column DEFAULT(NULL) in SQLite.swift 如何使用默认值使闭包可选 - How to make a closure optional with a default value 如何在我的 GameKit 游戏中避免这些循环引用? 我正在使用 GKAgents2D 和 GKBehaviours - How can I avoid these circular references in my GameKit game? I'm using GKAgents2D and GKBehaviours 将生产变更部署到生产环境后,如何在CKRecord中为字段添加默认值? - How do I add a default value for field in CKRecord when deploy changes to production? 在 WidgetKit 中,如何从通过 a.network 调用获得的动态选项设置默认意图值? - In WidgetKit, how do I set a default intent value from dynamic options obtained via a network call? 我怎么做五彩纸屑? - How do I make confetti? 如何在 WKWebView 中设置默认缩放 - How do I set a default zoom in a WKWebView 如何使以编程方式生成的 UIButton 在按下时执行默认动画? - How to make programmatically generated UIButton do default animation on press? 价值达到无穷大太快,我该如何阻止这种情况发生? (如何让程序存储更大的数字?) - Value reaches infinity too fast, how do I stop that from happening? (how do I make the program store higher numbers?)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM