---
title: "init(coder:rootView:)"
framework: swiftui
role: symbol
role_heading: Initializer
path: "swiftui/nshostingview/init(coder:rootview:)"
---

# init(coder:rootView:)

Creates a hosting view object from an archive and the specified SwiftUI view.

## Declaration

```swift
@MainActor @preconcurrency init?(coder: NSCoder, rootView: Content)
```

## Parameters

- `coder`: The decoder to use during initialization.
- `rootView`: The root view of the SwiftUI view hierarchy that you want to manage using this hosting view.
