<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.15.0 -",
    "tvOS: 13.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 6.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreData",
  "identifier" : "/documentation/CoreData/NSPersistentCloudKitContainer",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Core Data"
    ],
    "preciseIdentifier" : "c:objc(cs)NSPersistentCloudKitContainer"
  },
  "title" : "NSPersistentCloudKitContainer"
}
-->

# NSPersistentCloudKitContainer

A container that encapsulates the Core Data stack in your app, and mirrors select persistent stores to a CloudKit private database.

```
class NSPersistentCloudKitContainer
```

## Overview

[`NSPersistentCloudKitContainer`](/documentation/CoreData/NSPersistentCloudKitContainer) is a subclass of [`NSPersistentContainer`](/documentation/CoreData/NSPersistentContainer) capable of managing both CloudKit-backed and noncloud stores.

By default, [`NSPersistentCloudKitContainer`](/documentation/CoreData/NSPersistentCloudKitContainer) contains a single store description, which Core Data assigns to the first CloudKit container identifier in an app’s entitlements. Use [`NSPersistentCloudKitContainerOptions`](/documentation/CoreData/NSPersistentCloudKitContainerOptions) to customize this behavior or create additional store descriptions with backing by different containers.

For more information about setting up multiple stores, see [Setting Up Core Data with CloudKit](/documentation/CoreData/setting-up-core-data-with-cloudkit).

## Topics

### Accessing Records

[`recordForManagedObjectID:`](/documentation/CoreData/NSPersistentCloudKitContainer/recordForManagedObjectID:)

Returns the CloudKit record for the specified managed object ID.

[`recordsForManagedObjectIDs:`](/documentation/CoreData/NSPersistentCloudKitContainer/recordsForManagedObjectIDs:)

Returns a dictionary that contains the CloudKit records for the specified managed object IDs.

[`recordIDForManagedObjectID:`](/documentation/CoreData/NSPersistentCloudKitContainer/recordIDForManagedObjectID:)

Returns the CloudKit record ID for the specified managed object ID.

[`recordIDsForManagedObjectIDs:`](/documentation/CoreData/NSPersistentCloudKitContainer/recordIDsForManagedObjectIDs:)

Returns a dictionary that contains the CloudKit record IDs for the specified managed object IDs.

### Checking Permissions

[`canUpdateRecord(forManagedObjectWith:)`](/documentation/CoreData/NSPersistentCloudKitContainer/canUpdateRecord(forManagedObjectWith:))

Returns a Boolean value that indicates whether the user can modify the managed object’s underlying CloudKit record.

[`canDeleteRecord(forManagedObjectWith:)`](/documentation/CoreData/NSPersistentCloudKitContainer/canDeleteRecord(forManagedObjectWith:))

Returns a Boolean value that indicates whether the user can delete the managed object’s underlying CloudKit record.

[`canModifyManagedObjects(in:)`](/documentation/CoreData/NSPersistentCloudKitContainer/canModifyManagedObjects(in:))

Returns a Boolean value that indicates whether the user can modify the specified persistent store.

### Sharing Objects

[Accepting Share Invitations in a SwiftUI App](/documentation/CoreData/accepting-share-invitations-in-a-swiftui-app)

Adapt your app to use UIKit’s application and scene delegates so it can process CloudKit share invitations.

[`acceptShareInvitationsFromMetadata:intoPersistentStore:completion:`](/documentation/CoreData/NSPersistentCloudKitContainer/acceptShareInvitationsFromMetadata:intoPersistentStore:completion:)

Accepts one or more invitations to participate in sharing using the specified metadata.

[`fetchParticipantsMatchingLookupInfos:intoPersistentStore:completion:`](/documentation/CoreData/NSPersistentCloudKitContainer/fetchParticipantsMatchingLookupInfos:intoPersistentStore:completion:)

Fetches all participants that match the specified critieria.

[`fetchSharesInPersistentStore:error:`](/documentation/CoreData/NSPersistentCloudKitContainer/fetchSharesInPersistentStore:error:)

Returns an array that contains all share records in the specified persistent store.

[`fetchSharesMatchingObjectIDs:error:`](/documentation/CoreData/NSPersistentCloudKitContainer/fetchSharesMatchingObjectIDs:error:)

Returns a dictionary that contains the share records that CloudKit associates with specified managed object IDs.

[`persistUpdatedShare:inPersistentStore:completion:`](/documentation/CoreData/NSPersistentCloudKitContainer/persistUpdatedShare:inPersistentStore:completion:)

Saves the share record and schedules it for export to iCloud.

[`shareManagedObjects:toShare:completion:`](/documentation/CoreData/NSPersistentCloudKitContainer/shareManagedObjects:toShare:completion:)

Associates the specified managed objects with a new or existing share record.

### Purging Record Zones

[`purgeObjectsAndRecordsInZoneWithID:inPersistentStore:completion:`](/documentation/CoreData/NSPersistentCloudKitContainer/purgeObjectsAndRecordsInZoneWithID:inPersistentStore:completion:)

Deletes all CloudKit records in the specified record zone, along with their corresponding managed objects.

### Promoting Your Schema

[`initializeCloudKitSchema(options:)`](/documentation/CoreData/NSPersistentCloudKitContainer/initializeCloudKitSchema(options:))

Creates the CloudKit schema for all stores in the container that manage a CloudKit database.

[`NSPersistentCloudKitContainerSchemaInitializationOptions`](/documentation/CoreData/NSPersistentCloudKitContainerSchemaInitializationOptions)

Options that control the behavior when promoting the container’s schema to CloudKit.

### Monitoring Container Events

[`NSPersistentCloudKitContainer.Event`](/documentation/CoreData/NSPersistentCloudKitContainer/Event)

An object that represents activity in a persistent CloudKit container.

[`NSPersistentCloudKitContainer.EventType`](/documentation/CoreData/NSPersistentCloudKitContainer/EventType)

The type of event in a persistent CloudKit container, either setup, import, or export.

[`NSPersistentCloudKitContainerEventRequest`](/documentation/CoreData/NSPersistentCloudKitContainerEventRequest)

A request to fetch setup, import, or export events in a persistent CloudKit container.

[`NSPersistentCloudKitContainerEventResult`](/documentation/CoreData/NSPersistentCloudKitContainerEventResult)

The result of a request to fetch persistent CloudKit container events.

[`eventChangedNotification`](/documentation/CoreData/NSPersistentCloudKitContainer/eventChangedNotification)

A notification that contains details about an event in a persistent CloudKit container.

[`eventNotificationUserInfoKey`](/documentation/CoreData/NSPersistentCloudKitContainer/eventNotificationUserInfoKey)

The user info dictionary key for the persistent CloudKit container event.



---

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)