<!--
{
  "availability" : [
    "iOS: 10.0.0 -",
    "iPadOS: 10.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.12.0 -",
    "tvOS: 10.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 3.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreData",
  "identifier" : "/documentation/CoreData/NSPersistentContainer/init(name:managedObjectModel:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Core Data"
    ],
    "preciseIdentifier" : "c:objc(cs)NSPersistentContainer(im)initWithName:managedObjectModel:"
  },
  "title" : "init(name:managedObjectModel:)"
}
-->

# init(name:managedObjectModel:)

Create a container with the specified name and managed object model.

```
init(name: String, managedObjectModel model: NSManagedObjectModel)
```

## Parameters

`name`

The name used by the persistent container.

`model`

The managed object model to be used by the persistent container.

## Return Value

A persistent container initialized with the given name and model.

## Discussion

By default, the provided name value of the container is used as the name of the persisent store associated with the container. Passing in the [`NSManagedObjectModel`](/documentation/CoreData/NSManagedObjectModel) object overrides the lookup of the model by the provided name value.

---

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)