<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.10.0 -",
    "tvOS: -",
    "visionOS: 1.0.0 -",
    "watchOS: 3.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CloudKit",
  "identifier" : "/documentation/CloudKit/CKRecord/ID",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "CloudKit"
    ],
    "preciseIdentifier" : "c:objc(cs)CKRecordID"
  },
  "title" : "CKRecord.ID"
}
-->

# CKRecord.ID

An object that uniquely identifies a record in a database.

```
class ID
```

## Overview

A record ID object consists of a name string and a zone ID. The name string is an ASCII string that doesn’t exceed 255 characters in length. When you create a record without specifying a record ID, the ID name string derives from a UUID and is, therefore, unique. When creating your own record ID objects, you can use names that have more meaning to your app or to the user, as long as each name is unique within the specified zone. For example, you might use a document name for the name string.

CloudKit uniques records by recordID within a specified database, but you can reuse record IDs in different databases. Each container has a public and a private database, and the private database is different for each unique user. This configuration provides for the reusing of record IDs in each user’s private database, but ensures that only one record uses a specific record ID in the public database.

CloudKit generally creates record IDs when it first saves a new record, but you might manually instantiate instances of `CKRecordID` in  specific situations. For example, you must create an instance when saving a record in a zone other than the default zone. You also instantiate instances of `CKRecordID` when retrieving specific records from a database.

Don’t subclass `CKRecordID`.

### Interacting with Record IDs

After you create a `CKRecordID` object, interactions with that object typically involve creating a new record or retrieving an existing record from a database.

You might also use record IDs when you can’t use a [`CKRecord.Reference`](/documentation/CloudKit/CKRecord/Reference) object to refer to a record. References are only valid within a single zone of a database. To refer to objects outside of the current zone or database, save the strings in the record’s `CKRecordID` and [`CKRecordZone.ID`](/documentation/CloudKit/CKRecordZone/ID) objects. When you want to retrieve the record later, use those strings to recreate the record and zone ID objects so that you can fetch the record.

#### Creating Record IDs for New Records

To assign a custom record ID to a new record, you must create the `CKRecordID` object first. You need to know the intended name and zone information for that record, which might also require creating a [`CKRecordZone.ID`](/documentation/CloudKit/CKRecordZone/ID) object. After creating the record ID object, initialize your new record using its [`init(recordType:recordID:)`](/documentation/CloudKit/CKRecord/init(recordType:recordID:)) method.

#### Using Record IDs to Fetch Records

Use a record ID to fetch the corresponding [`CKRecord`](/documentation/CloudKit/CKRecord) object from a database quickly. You perform the fetch operation using a [`CKFetchRecordsOperation`](/documentation/CloudKit/CKFetchRecordsOperation) object or the [`fetch(withRecordID:completionHandler:)`](/documentation/CloudKit/CKDatabase/fetch(withRecordID:completionHandler:)) method of the [`CKDatabase`](/documentation/CloudKit/CKDatabase) class. In both cases, CloudKit returns the record asynchronously using the handler you provide.

## Topics

### Creating a Record ID

[`init(recordName:)`](/documentation/CloudKit/CKRecord/ID/init(recordName:))

Creates a new record ID with the specified name in the default zone.

[`init(recordName:zoneID:)`](/documentation/CloudKit/CKRecord/ID/init(recordName:zoneID:))

Creates a new record ID with the specified name and zone information.

[`initWithRecordName:zoneID:`](/documentation/CloudKit/CKRecordID/initWithRecordName:zoneID:)

Creates a new record ID with the specified name and zone information.

[`CKRecordNameZoneWideShare`](/documentation/CloudKit/CKRecordNameZoneWideShare)

The name of a share record that manages a shared record zone.

### Getting the Record ID’s Name

[`recordName`](/documentation/CloudKit/CKRecord/ID/recordName)

The unique name of the record.

### Getting the Record ID’s Zone

[`zoneID`](/documentation/CloudKit/CKRecord/ID/zoneID)

The ID of the zone that contains the record.



---

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)