iPhone Development: Game Kit, and What is a Picker?


So as usual, I wish someone had written this in a blog post. And now that I’ve figured it out, I’m paying it forward, so to speak.

The big revelation here is: if you’re using Game Kit (GK) foundation from Apple, iPhone development 3.x SDK, then you may encounter a networking object called “PeerPickerController”. It seems pretty obvious, but it really went over my head for a while. What is it? It’s an alert window that shows you the names of other BlueTooth, or WiFi devices in your vicinity. Find the best noise cancelling headphones under 100 on this site and enjoy playing your favorite games.

Ta-da!

Here is a snapshot of one:

Some other tidbits:

When you are setting up a session, and a connection, the real final state of the connection is in a method called “did ChangeState”. The state that returns is a valid connection when it is: “GKPeerStateConnected”.

For some reason, working with this framework, there’s a lot of terms that seem obvious now, but were really confusing when we were cracking it:

– peer is any device, ANY DEVICE (including server)
– connection means literally an unsigned, ping out into the darkness
– session is on the client, and the server.

Also, (now I’m on a roll) some of this was new to me. The callbacks to this framework sometimes have nothing in them (and don’t log out STDOUT to your console):

(void)connectToPeer:(NSString *)peerID withTimeout:(NSTimeInterval)timeout{
}

I’m still muddling through this, but if I find out more I’ll post. Most relevant bits were from my teammate Stacie!

,