iOS Developer Library

Developer

MultipeerConnectivity Framework Reference MCBrowserViewControllerDelegate Protocol Reference

Options
Deployment Target:

On This Page
Language:

MCBrowserViewControllerDelegate

Inheritance


Not Applicable

Conforms To


Import Statement


Swift

import MultipeerConnectivity

Objective-C

@import MultipeerConnectivity;

Availability


Available in iOS 7.0 and later.

The MCBrowserViewControllerDelegate protocol defines the methods that your delegate object can implement to handle events related to the MCBrowserViewController class.

  • Called when a new peer is discovered to decide whether to show it in the user interface.

    Declaration

    Swift

    optional func browserViewController(_ browserViewController: MCBrowserViewController!, shouldPresentNearbyPeer peerID: MCPeerID!, withDiscoveryInfo info: [NSObject : AnyObject]!) -> Bool

    Objective-C

    - (BOOL)browserViewController:(MCBrowserViewController *)browserViewController shouldPresentNearbyPeer:(MCPeerID *)peerID withDiscoveryInfo:(NSDictionary *)info

    Parameters

    browserViewController

    The browser view controller object that discovered the new peer.

    peerID

    The unique ID of the nearby peer.

    info

    The info dictionary advertised by the discovered peer. For more information on the contents of this dictionary, see the documentation for initWithPeer:discoveryInfo:serviceType: in MCNearbyServiceAdvertiser Class Reference.

    Return Value

    This delegate method should return YEStrue if the newly discovered peer should be shown in the user interface, or NOfalse otherwise.

    Discussion

    If this method is not provided, all peers are shown.

    Import Statement

    Objective-C

    @import MultipeerConnectivity;

    Swift

    import MultipeerConnectivity

    Availability

    Available in iOS 7.0 and later.

  • Called when the browser view controller is dismissed with peers connected in a session. (required)

    Declaration

    Swift

    func browserViewControllerDidFinish(_ browserViewController: MCBrowserViewController!)

    Objective-C

    - (void)browserViewControllerDidFinish:(MCBrowserViewController *)browserViewController

    Parameters

    browserViewController

    The view controller that was dismissed.

    Discussion

    This call is intended to inform your app that the user has connected with nearby peers in a session and that the browser view controller has been dismissed. Upon receiving this delegate method call, your app must call dismissViewControllerAnimated:completion: to dismiss the view controller. Your app can also begin sending data to any connected peers, and should resume any UI updates that it may have temporarily suspended while the view controller was onscreen.

    Import Statement

    Objective-C

    @import MultipeerConnectivity;

    Swift

    import MultipeerConnectivity

    Availability

    Available in iOS 7.0 and later.

  • Called when the user cancels the browser view controller. (required)

    Declaration

    Swift

    func browserViewControllerWasCancelled(_ browserViewController: MCBrowserViewController!)

    Objective-C

    - (void)browserViewControllerWasCancelled:(MCBrowserViewController *)browserViewController

    Parameters

    browserViewController

    The browser view controller that was canceled.

    Discussion

    This call is intended to inform your app that the view controller has been dismissed because the user canceled the discovery process and is no longer interested in creating a communication session.

    When your app receives this delegate method call, your app must call dismissViewControllerAnimated:completion: to dismiss the view controller. Then, your app should handle the cancelation in whatever way is appropriate for your app, and then resume any UI updates that it may have temporarily suspended while the view controller was onscreen.

    Import Statement

    Objective-C

    @import MultipeerConnectivity;

    Swift

    import MultipeerConnectivity

    Availability

    Available in iOS 7.0 and later.