---
title: "init(browser:session:)"
framework: multipeerconnectivity
role: symbol
role_heading: Initializer
path: "multipeerconnectivity/mcbrowserviewcontroller/init(browser:session:)"
---

# init(browser:session:)

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

## Declaration

```swift
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 doc://com.apple.multipeerconnectivity/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

Return Value Returns an initialized object, or nil if an error occurred.

## Discussion

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

## See Also

### Initializing a Browser View Controller

- [init(serviceType:session:)](multipeerconnectivity/mcbrowserviewcontroller/init(servicetype:session:).md)
- [delegate](multipeerconnectivity/mcbrowserviewcontroller/delegate.md)
- [browser](multipeerconnectivity/mcbrowserviewcontroller/browser.md)
- [session](multipeerconnectivity/mcbrowserviewcontroller/session.md)
