init(displayName:)
Initializes a peer.
Declaration
init(displayName myDisplayName: String)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
displayNameparameter may not benilor an empty string.
Return Value
An initialized peer ID object.
Discussion
Call this method only when creating the local peer, not when you create objects that represent other devices.
This method throws an exception if the displayName value is too long, empty, or nil.
Each call to this method produces a unique peer ID, even for the same display name. If you need a device to maintain a consistent peer ID over time, you may want to archive and reuse it later instead of creating a new one every time your app starts advertising or browsing.