MCPeer object represents a peer in a multipeer session.
- iOS 7.0+
- macOS 10.10+
- tvOS 9.0+
You create a single peer ID object that represents the instance of your app running on the local device. The Multipeer Connectivity framework is responsible for creating peer ID objects that represent other devices.
To create a new peer ID for the local app and associate a display name with that ID, call
init(display. The peer’s name must be no longer than 63 bytes in UTF-8 encoding.
Each peer ID your app creates with
init(display is unique, even when supplying the same display name. If you want a device’s peer ID to be stable over time, don’t create a new peer ID every time your app begins advertising or browsing. Instead, archive the ID when you create it, and then unarchive it the next time you need it. If you need the peer ID to be tied to the display name, you can archive the name as well, and only create a new peer ID when the name changes, as illustrated in the following code fragment: