<!--
{
  "availability" : [
    "iOS: 15.0.0 -",
    "iPadOS: 15.0.0 -",
    "macCatalyst: 15.0.0 -",
    "macOS: 12.0.0 -",
    "tvOS: 15.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 8.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreData",
  "identifier" : "/documentation/CoreData/NSPersistentCloudKitContainer/purgeObjectsAndRecordsInZoneWithID:inPersistentStore:completion:",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Core Data"
    ],
    "preciseIdentifier" : "c:objc(cs)NSPersistentCloudKitContainer(im)purgeObjectsAndRecordsInZoneWithID:inPersistentStore:completion:"
  },
  "title" : "purgeObjectsAndRecordsInZoneWithID:inPersistentStore:completion:"
}
-->

# purgeObjectsAndRecordsInZoneWithID:inPersistentStore:completion:

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

```
- (void) purgeObjectsAndRecordsInZoneWithID:(CKRecordZoneID *) zoneID inPersistentStore:(NSPersistentStore *) persistentStore completion:(void (^)(CKRecordZoneID *purgedZoneID, NSError *purgeError)) completion;
```

## Parameters

`zoneID`

The ID of the record zone to purge.

`persistentStore`

The persistent store that manages the CloudKit database containing the record zone. Use `nil` to attempt the purge in each of the container’s persistent stores that manages a CloudKit database.

`completion`

The handler to invoke after Core Data purges the CloudKit records and managed objects.

## Discussion

The `completion` callback returns no value and takes the following parameters:

- The ID of the purged record zone, or `nil` if the purge fails.
- An error object that contains information about a problem, or `nil` if Core Data successfully purges the record zone.

If `persistentStore` is `nil`, the method invokes the completion handler once for each of the persistent container’s stores that manages a CloudKit database.

---

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)