<!--
{
  "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/MCBrowserViewController/init(browser:session:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Multipeer Connectivity"
    ],
    "preciseIdentifier" : "c:objc(cs)MCBrowserViewController(im)initWithBrowser:session:"
  },
  "title" : "init(browser:session:)"
}
-->

# init(browser:session:)

Initializes a browser view controller with the provided browser and session.

```
init(browser: MCNearbyServiceBrowser, session: MCSession)
```

## Parameters

`browser`

An object that the browser view controller uses for browsing. This is usually an instance of `MCNearbyServiceBrowser`. However, if your app is using a custom discovery scheme, you can instead pass any custom subclass that calls the methods defined in the [`MCNearbyServiceBrowserDelegate`](/documentation/MultipeerConnectivity/MCNearbyServiceBrowserDelegate) protocol on its delegate when peers are found and lost.
  
  > Important:
  > If you want the browser view controller to manage the browsing process, the browser object must not be actively browsing, and its delegate must be `nil`.

`session`

The multipeer session into which the invited peers are connected.

## Return Value

Returns an initialized object, or `nil` if an error occurred.

## Discussion

This method throws an exception if the `browser` or `session` parameters do not contain valid objects.

---

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)