iOS Developer Library

Developer

MultipeerConnectivity Framework Reference MCPeerID Class Reference

Options
Deployment Target:

On This Page
Language:

MCPeerID

The MCPeerID class represents a peer in a multipeer session. More...

Inheritance


Import Statement


import MultipeerConnectivity @import MultipeerConnectivity;

Availability


Available in iOS 7.0 and later.
  • init(displayName:) initWithDisplayName: Designated Initializer

    Initializes a peer.

    Declaration

    Swift

    init!(displayName myDisplayName: String!)

    Objective-C

    - (instancetype)initWithDisplayName:(NSString *)myDisplayName

    Parameters

    myDisplayName

    The display name for the local peer. If you use the multipeer browser view controller, this name is shown.

    The display name is intended for use in UI elements, and should be short and descriptive of the local peer. The maximum allowable length is 63 bytes in UTF-8 encoding. The displayName parameter may not be nil or an empty string.

    Return Value

    Returns an initialized object.

    Discussion

    This method should be called only when creating the local peer, not for creating objects that represent other devices.

    This method throws an exception if the displayName value is too long, empty, or nil.

    Import Statement

    import MultipeerConnectivity

    Availability

    Available in iOS 7.0 and later.

  • The display name for this peer. (read-only)

    Declaration

    Swift

    var displayName: String! { get }

    Objective-C

    @property(readonly, nonatomic) NSString *displayName

    Discussion

    For the local peer, this property is set when the object is initialized and cannot be changed.

    For other peer objects provided to you by the framework, this property is provided by the peer and cannot be changed.

    Import Statement

    import MultipeerConnectivity

    Availability

    Available in iOS 7.0 and later.