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

时间:2016-08-31 12:21:14

标签: swift swift3

i have this function in my code:

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

and it gaves me this warning:

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

and it offers me the possibility to make the func private, or to insert @nonobjc to silence the warning? what should i do?

1 个答案:

答案 0 :(得分:0)

好的,感谢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
        }