GKPeerPickerControllerDelegate Protocol Reference

Conforms to
Framework
/System/Library/Frameworks/GameKit.framework
Availability
Available in iOS 3.0 and later.
Companion guide
Declared in
GKPeerPickerController.h

Overview

The GKPeerPickerControllerDelegate protocol is implemented on an object to customize the behavior of a GKPeerPickerController object. The delegate is called by the peer picker to create a session object and to respond as the session is configured by the controller.

Tasks

Creating a Session for the Peer Picker

Responding to Connection Messages

Responding When the User Cancels the Connection Attempt

Instance Methods

peerPickerController:didConnectPeer:toSession:

Tells the delegate that the controller connected a peer to the session.

- (void)peerPickerController:(GKPeerPickerController *)picker didConnectPeer:(NSString *)peerID toSession:(GKSession *)session
Parameters
picker

The controller that connected the peer.

peerID

The identification string for the peer that connected to the session.

session

The session that the peer is connected to.

Discussion

Once a peer is connected to the session, your application should take ownership of the session, dismiss the peer picker, and then use the session to communicate with the other peer.

Availability
  • Available in iOS 3.0 and later.
Declared In
GKPeerPickerController.h

peerPickerController:didSelectConnectionType:

Tells the delegate that the user selected a connection type.

- (void)peerPickerController:(GKPeerPickerController *)picker didSelectConnectionType:(GKPeerPickerConnectionType)type
Parameters
picker

The controller for the peer picker dialog.

type

The type of network connection chosen by the user.

Discussion

If the peer picker is configured to allow users to choose between multiple connection types, this method is called when users select the connection type they want to use. Your delegate implements this method if you want to override the behavior for a particular connection type.

- (void)peerPickerController:(GKPeerPickerController *)picker didSelectConnectionType:(GKPeerPickerConnectionType)type {
    if(type == GKPeerPickerConnectionTypeOnline) {
        [picker dismiss];
        [picker autorelease];
// Display your own user interface here.
}
Availability
  • Available in iOS 3.0 and later.
Declared In
GKPeerPickerController.h

peerPickerController:sessionForConnectionType:

Asks the delegate to return a session for the specified connection type.

- (GKSession *)peerPickerController:(GKPeerPickerController *)picker sessionForConnectionType:(GKPeerPickerConnectionType)type
Parameters
picker

The controller requesting the session.

type

The type of connection the controller wants to configure.

Discussion

Your delegate is responsible for providing a GKSession to use to find and connect to other devices. When the peer picker needs a session, it calls this method. Your application can either create a new session or return a previously created session to the peer picker. The session that your application returns to the peer picker must advertise itself as a peer (GKSessionModePeer).

If your delegate does not implement this method and the user selected a network of type GKPeerPickerConnectionTypeNearby, the peer controller allocates a new session that advertises itself as a peer (GKSessionModePeer) with the default sessionID and displayName parameters.

Special Considerations

In iOS 3.0, your delegate receives requests only for networks of type GKPeerPickerConnectionTypeNearby.

Availability
  • Available in iOS 3.0 and later.
Declared In
GKPeerPickerController.h

peerPickerControllerDidCancel:

Tells the delegate that the user canceled the connection attempt.

- (void)peerPickerControllerDidCancel:(GKPeerPickerController *)picker
Parameters
picker

The controller for the peer picker dialog.

Discussion

After this method returns, the controller dismisses the picker interface.

Availability
  • Available in iOS 3.0 and later.
Declared In
GKPeerPickerController.h