<!--
{
  "availability" : [
    "iOS: 7.0.0 - 27.0.0",
    "iPadOS: 7.0.0 - 27.0.0",
    "macCatalyst: 13.1.0 - 27.0.0",
    "macOS: 10.10.0 - 27.0.0",
    "tvOS: 10.0.0 - 27.0.0",
    "visionOS: 1.0.0 - 27.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "MultipeerConnectivity",
  "identifier" : "/documentation/MultipeerConnectivity/MCSession/init(peer:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Multipeer Connectivity"
    ],
    "preciseIdentifier" : "c:objc(cs)MCSession(im)initWithPeer:"
  },
  "title" : "init(peer:)"
}
-->

# init(peer:)

Creates a Multipeer Connectivity session.

```
convenience init(peer myPeerID: MCPeerID)
```

## Parameters

`myPeerID`

A local identifier that represents the device on which your app is currently running.

## Return Value

The initialized session object, or `nil` if an error occurs.

## Discussion

This method is equivalent to calling [`init(peer:securityIdentity:encryptionPreference:)`](/documentation/MultipeerConnectivity/MCSession/init(peer:securityIdentity:encryptionPreference:)) with a `nil` identity and an encryption setting that varies based on which version of the SDK was used to link the application. On apps linked on or after iOS 9, the encryption is set to [`MCEncryptionPreference.required`](/documentation/MultipeerConnectivity/MCEncryptionPreference/required). On apps linked prior to iOS 9, the encryption is set to [`MCEncryptionPreference.optional`](/documentation/MultipeerConnectivity/MCEncryptionPreference/optional).

This method throws an exception if the provided peer ID object is invalid or `nil`.

For more information, see [`Initiating a Session`](/documentation/MultipeerConnectivity/MCSession#Initiating-a-Session).

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)