Reputation: 63
I am implementing online gameplay for my small turn-based iOS app. I am having some trouble implementing the "GKSavedGameListener" protocol because I am not sure how to register an object as a listener (or set an object as a delegate).
I was having similar trouble with "GKLocalPlayerListener", but found GKLocalPlayer allowed registration via "registerListener:". I found apple's documentation on this kind of lacking. Unfortunately, it does not look like "GKSavedGameListener" is as easy to implement.
I see that GKLocalPlayer conforms to "GKSavedGameListener", but does not seem to implement the optional functions in the protocol (at least I don't see them in GKLocalPlayer.h).
I am specifically interested in "player:didModifySavedGame:".
How can I implement custom behavior in the "GKSavedGameListener" protocol functions?
Upvotes: 0
Views: 194
Reputation: 4177
Per guidance in Apple's docs: https://developer.apple.com/documentation/gamekit/gklocalplayerlistener?changes=_7&language=objc, GKLocalPlayerListener
inherits from, among other things, GKSavedGameListener
. You only need implement for GKLocalPlayerListener
and you get messages for all four.
After you register, configure your class to conform to GKLocalPlayerListener
so that your class receives those:
@interface MyGameKitHelperClass : UIViewController
<
GKLocalPlayerListener
>
You can then implement the functions in your class which are called when your class receives the appropriate message.
-(void)player:(GKPlayer *)player didModifySavedGame:(GKSavedGame *)savedGame
{
}
-(void)player:(GKPlayer *)player hasConflictingSavedGames:(NSArray *)savedGames
{
}
// or whichever functions you're interested in.
Upvotes: 1