---
title: newBackgroundContext()
framework: coredata
role: symbol
role_heading: Instance Method
path: coredata/nspersistentcontainer/newbackgroundcontext()
---

# newBackgroundContext()

Returns a new managed object context that executes on a private queue.

## Declaration

```swift
func newBackgroundContext() -> NSManagedObjectContext
```

## Mentioned in

Using Core Data in the background

## Return Value

Return Value A newly created private managed object context.

## Discussion

Discussion Invoking this method causes the persistent container to create and return a new NSManagedObjectContext with the concurrencyType set to NSManagedObjectContextConcurrencyType.privateQueueConcurrencyType. This new context will be associated with the NSPersistentStoreCoordinator directly and is set to consume NSManagedObjectContextDidSave broadcasts automatically.

## See Also

### Acquiring Contexts

- [viewContext](coredata/nspersistentcontainer/viewcontext.md)
