swift - 如何确定 receivedTurnEventFor 是否是邀请?
问题描述
在阅读了各种问题后,我了解到 GKTurnBasedMatches 的邀请要等到轮到被邀请的用户时才会发送。该邀请是通过“ func player(_ player: GKPlayer, receivedTurnEventFor match” 类处理的。
但我不确定此时如何处理邀请?我想为用户提供接受/拒绝邀请的机会。这是我应该写代码的地方:
如果收到回合事件 == 邀请 { 请求拒绝/接受 }
如果是这样,我该怎么做?如何确定是否有邀请,以及如何接受/拒绝该邀请?
解决方案
我相信我已经通过使用以下代码解决了这个问题:
if match.currentParticipant?.status == .invited {
print("Was invited")
// Present option to act on invite
}
推荐阅读
- sql - 将一个数据库中的表插入另一个数据库
- java - 应用程序未在高于 22 的 API 上运行
- python - 为什么我嵌入在 tkinter 框架中的 matplotlib 图形在平移后才显示其 x 轴值和网格线?
- php - 基于数据库记录在laravel中创建带有子数组的数组
- python - 使用 selenium docker 独立时的不一致
- android - Jetpack compose 中的 Lottie 动画比例类型
- dax - 如何有条件地计算前几天?
- flask - Flask loguru - 在日志消息中显示堆栈跟踪
- r - MissForest 中的并行化
- csv - 将 CSV 文件加载到 db2 表中时,特殊字符会导致问题