Class

CKRecordZone

The definition of a custom area for organizing related records in a database.

Overview

Zones are an important part of how you organize your data. The public, private and shared databases have a single default zone. In the private database you can use CKRecordZone objects to create additional custom zones as needed. Use custom zones to arrange and encapsulate groups of related records in the private database. Custom zones support other capabilities too, such as the ability to write multiple records as a single atomic transaction.

Treat each custom zone as a single unit of data that is separate from every other zone in the database. Inside the zone, you add records as you would anywhere else. You can also create links between the records inside a zone by using the CKReference class. However, the CKReference class does not support cross-zone linking, so each reference object must point to a record in the same zone as the current record.

Use the CKRecordZone class as-is and do not subclass.

Creating a Custom Record Zone

For the most part, you use instances of this class to create and manage custom zones. Although you can use this class to retrieve a database’s default zone, most operations act on records in the default zone by default, so you rarely need to specify it explicitly.

To create a custom zone, use CKRecordZone to create the zone object, and then save that zone to the user’s private database using a CKModifyRecordZonesOperation object. You cannot save any records in the zone until you save it to the database. When creating records, explicitly specify the zone ID if you want the records to reside in a specific zone; otherwise, they will be saved to the default zone. You cannot create custom zones in a public database.

After creating a CKRecordZone object and saving it to the database, you do not interact with the object much. Instead, most interactions occur with its associated CKRecordZoneID object, which you use to refer to the zone when creating records.

Topics

Getting the Default Record Zone

class func `default`()

Returns the default zone for records.

Initializing a Record Zone

init(zoneName: String)

Initializes and returns a record zone object with the specified name.

init(zoneID: CKRecordZoneID)

Initializes and returns a record zone object using the specified ID.

Getting the Zone Attributes

var zoneID: CKRecordZoneID

The unique ID of the zone.

var capabilities: CKRecordZoneCapabilities

The capabilities supported by the zone.

class CKRecordZoneID

An object that uniquely identifies a record zone in a database.

Constants

let CKRecordZoneDefaultName: String

The name of the default zone. Use this constant when you need to refer to the default zone by name, perhaps when creating a zone ID. The default zone has no special capabilities.

struct CKRecordZoneCapabilities

Constants indicating the special capabilities supported by a zone.

Relationships

Inherits From

See Also

Records

class CKRecord

A dictionary of key-value pairs that you use to fetch and save your app's data.

class CKReference

A reference used to create a many-to-one relationship between records in a database.

protocol CKRecordValue

The protocol that provides strong type checking for objects that the CloudKit framework stores on the server.

Record Operations

Asynchronously fetch or modify records.