gpt4 book ai didi

swift - 实例方法 'match(match:player:didChangeState:)'几乎匹配协议(protocol) 'match(_:player:didChange:)'的可选要求 'GKMatchDelegate'

转载 作者:行者123 更新时间:2023-11-30 13:06:53 24 4
gpt4 key购买 nike

我的代码中有这个函数:

func match(match: GKMatch, player playerID: String, didChangeState state: GKPlayerConnectionState) {
if (match != self.match) {
print("Wrong match")
return
}

它给了我这个警告:

Instance method 'match(match:player:didChangeState:)' nearly matches optional requirement 'match(_:player:didChange:)' of protocol 'GKMatchDelegate'

它为我提供了将func设为私有(private)的可能性,或者插入@nonobjc来消除警告?我应该怎么办?

最佳答案

好的,感谢 https://stackoverflow.com/users/1187415/martin-r (和文档)只需将其更改为:

 func match(_ match: GKMatch, player playerID: String, didChange state: GKPlayerConnectionState) {
if (match != self.match) {
print("Wrong match")
return
}

关于swift - 实例方法 'match(match:player:didChangeState:)'几乎匹配协议(protocol) 'match(_:player:didChange:)'的可选要求 'GKMatchDelegate',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39249522/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com