<!--
{
  "availability" : [
    "iOS: 8.0.0 - 15.0.0",
    "iPadOS: 8.0.0 - 15.0.0",
    "macCatalyst: 13.1.0 - 15.0.0",
    "macOS: 10.10.0 - 12.0.0",
    "tvOS: 9.0.0 - 15.0.0",
    "visionOS: 1.0.0 - 1.0.0",
    "watchOS: 3.0.0 - 8.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "CloudKit",
  "identifier" : "/documentation/CloudKit/CKDatabase/perform(_:inZoneWith:completionHandler:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "CloudKit"
    ],
    "preciseIdentifier" : "c:objc(cs)CKDatabase(im)performQuery:inZoneWithID:completionHandler:"
  },
  "title" : "perform(_:inZoneWith:completionHandler:)"
}
-->

# perform(_:inZoneWith:completionHandler:)

Searches for records matching a predicate in the specified record zone.

```
func perform(_ query: CKQuery, inZoneWith zoneID: CKRecordZone.ID?, completionHandler: @escaping @Sendable ([CKRecord]?, (any Error)?) -> Void)
```

## Parameters

`query`

The query that contains the search parameters. For more information, see [`CKQuery`](/documentation/CloudKit/CKQuery).

`zoneID`

The identifier of the record zone to search. If you’re searching a shared database, provide a record zone identifier; otherwise, you can specify `nil` to search all record zones in the database.

`completionHandler`

The closure to execute with the search results.

## Discussion

The completion handler takes the following parameters:

- The records that match the specified query, or `nil` if there’s an error.
- An error if a problem occurs, or `nil` if CloudKit completes the search successfully.

For information on a more convenient way to search a database, see [`records(matching:inZoneWith:desiredKeys:resultsLimit:)`](/documentation/CloudKit/CKDatabase/records(matching:inZoneWith:desiredKeys:resultsLimit:)).

---

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)