实例方法 'match(match:player:didChangeState:)' 几乎符合协议 'GKMatchDelegate' 的可选要求 'match(_:player:didChange:)'

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

我的代码中有这个函数:

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 设为私有,或者插入 @nonobjc 以消除警告? 我应该怎么办?

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

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