An object that uniquely identifies a record zone in a database.
- iOS 8.0+
- macOS 10.10+
- Mac Catalyst 13.0+Beta
- tvOS 9.0+
- watchOS 3.0+
Zones are a way to group related records together. You create zone ID objects when you want to fetch an existing zone object or create a new zone with a specific name.
A record zone ID distinguishes one zone from another by a name string and the ID of the user that created the zone. Both strings must be ASCII strings that do not exceed 255 characters. For automatically created record zones, the ID name string is based on a UUID and is therefore guaranteed to be unique. When creating your own record zone ID objects, you are free to use names that have more meaning to your app or to the user, providing each zone name is unique within the specified database. The owner name must be either the current user name (obtained from the
fetch method) or the name of another user.
When creating new record zones, make the name string in the record zone ID unique in the target database. Public databases do not support custom zones, and zones in a private database can only be created by the user that owns the database.
This class is not intended to be subclassed.
Interacting with Record Zone IDs
After you create a
CKRecord object, interactions with that object typically include:
CKRecordobject so that you can fetch or create records in that zone.
Retrieving an existing
CKRecordobject from the database.
You do not need to create a
CKRecord object in order to create a
CKRecord object. The
CKRecord class has initialization methods that create a record zone ID using the name string you provide.
Creating Record Zone IDs to Use with Records
To create a new record in a custom zone, first create a
CKRecord object that specifies the zone name. Use the record zone ID to create a
CKRecord and then use the record ID to create the record itself.
Fetching a Record Zone Object from the Database
To fetch a
CKRecord object from a database, use a
CKFetch object or the fetchRecordZoneWithID:completion: method of the
CKDatabase class. Both techniques take a
CKRecord object that you provide and retrieve the corresponding record zone object asynchronously. If you use the operation object, you can retrieve multiple record zones at the same time.