How to properly use `GKLocalPlayer.anonymousGuestPlayer` for a computer player

Hi, I am trying to create an anonymous guest player to act as a computer player to fill in for an unfilled multiplayer slot.

Invoking the register method after the user has authenticated causes an exception to be thrown.

[GKAnonymousGuestPlayerInternal registerListener:]: unrecognized selector sent to instance

class ComputerPlayer: NSObject, GKLocalPlayerListener {
    let player: GKLocalPlayer

    override init() {
        self.player = GKLocalPlayer.anonymousGuestPlayer(withIdentifier: "local_anon_guest")
        super.init()
    }

    func register() {
        self.player.register(self) // <-- this throws "-[GKAnonymousGuestPlayerInternal registerListener:]: unrecognized selector sent to instance"
    }

    func player(_ player: GKPlayer, receivedTurnEventFor match: GKTurnBasedMatch, didBecomeActive: Bool) {
        ...
    }

}

There is very little documentation on its proper use, and after hours of searching I have not been able to find a single other example of the anonymous guest player API being used.

Can someone guide me on the proper use of this API?

Post not yet marked as solved Up vote post of 34tsdga Down vote post of 34tsdga
92 views