Framework

CloudKit

Store structured app and user data in iCloud containers that can be shared by all users of your app.

Overview

The CloudKit framework provides interfaces for moving data between your app and your iCloud containers.You use CloudKit to take your app’s existing data and store it in the cloud so that the user can access it on multiple devices. You can also store data in a public area where all users can access it.

Using the CloudKit Framework

CloudKit is not a replacement for your app’s existing data objects. Instead, CloudKit provides complementary services for managing the transfer of data to and from iCloud servers. Because it provides minimal offline caching support, CloudKit relies on the presence of the network and optionally a valid iCloud account. (A valid iCloud account is required only when you want to save data that is specific to a single user.) Apps can always store data in a public area that is readable by all users.

Records are at the heart of all data transactions in CloudKit. A record is a dictionary of key-value pairs that represents the data you want to save. You can add new keys and values to records at any time, and you can create links between related records to organize your data. The CKRecord class defines the interfaces for managing the contents of records. CloudKit also relies heavily on the use of NSOperation objects to manage the asynchronous transfer of data to and from the server.

Symbols

Classes

CKAcceptSharesOperation

An operation that accepts shared records.

CKAsset

A CKAsset object represents a large file associated with a record. Use asset objects to incorporate external files—such as image, sound, video, text, and binary data files—into your app’s records. You can also use assets in places where the data you want to assign to a field is more than a few kilobytes in size. To associate an asset with a record, assign it as the value of one of the record’s fields.

CKContainer

An encapsulation of content associated with an app, including content that is accessible to all users and content that is available only to a specific user.

CKDatabase

A conduit for accessing and for performing operations on the public and private data of an app container.

CKDatabaseNotification

A notification object about a database.

CKDatabaseOperation

The CKDatabaseOperation class is an abstract parent class for operations that act on the public or private databases in a container. Database operations typically involve fetching and saving records and other database objects, as well as queries on the contents of the database. You use the property of this class to tell the operation object which database to use when executing its task. Do not subclass this class or create instances of it. Instead, create instances of one of its concrete subclasses.

CKDatabaseSubscription

A subscription for database changes.

CKDiscoverAllContactsOperation

A CKDiscoverAllContactsOperation object retrieves the IDs of all discoverable users that are also in the user’s address book.

Deprecated
CKDiscoverAllUserIdentitiesOperation

An operation that finds all discoverable users in the device’s contacts.

CKDiscoveredUserInfo

A CKDiscoveredUserInfo object contains information about a discoverable user in a database. You do not create instances of this class yourself. Instead, use a CKDiscoverAllContactsOperation object or other means to retrieve these objects.

Deprecated
CKDiscoverUserIdentitiesOperation

An operation that fetches user identities.

CKDiscoverUserInfosOperation

A CKDiscoverUserInfosOperation object retrieves the IDs for discoverable users whose email addresses or user record IDs you already know. This operation returns information about the corresponding users.

Deprecated
CKFetchDatabaseChangesOperation

An operation that fetches changes to the database.

CKFetchNotificationChangesOperation

A CKFetchNotificationChangesOperation object retrieves unread CKNotification objects from a container. Notification objects contain the data associated with push notifications that have already been sent to an app. Fetch notification objects to identify changes that your app might have missed or to retrieve the complete push notification payload, which might have been truncated when it was delivered to the device.

CKFetchRecordChangesOperation

A CKFetchRecordChangesOperation object reports on the changed and deleted records in the specified record zone. Use this type of operation object to optimize fetch operations for locally managed sets of records. Specifically, use it when you maintain a local cache of your record data and need to synchronize that cache periodically with the server.

Deprecated
CKFetchRecordsOperation

A CKFetchRecordsOperation object retrieves CKRecord objects (whose IDs you already know) from iCloud. Use this operation to retrieve the entire contents of each record or only a subset of its contained values. As records become available, the operation object reports progress about the state of the operation to several different blocks, which you can use to process the results.

CKFetchRecordZoneChangesOperation

An operation that fetches record changes across the given record zone.

CKFetchRecordZoneChangesOptions

Options when fetching record zone changes.

CKFetchRecordZonesOperation

A CKFetchRecordZonesOperation object retrieves CKRecordZone objects (whose IDs you already know) from iCloud. Use this operation object to fetch record zones so that you can ascertain their capabilities.

CKFetchShareMetadataOperation

An operation that fetches shared record metadata for one or more shares.

CKFetchShareParticipantsOperation

An operation that fetches the participants of a shared record.

CKFetchSubscriptionsOperation

A CKFetchSubscriptionsOperation object retrieves CKSubscription objects (whose IDs you already know) from iCloud and can fetch all subscriptions associated with the current user. You might fetch subscription objects so you can examine or modify their parameters; for example, to adjust the delivery options for push notifications generated by the subscription.

CKFetchWebAuthTokenOperation

The CKFetchWebAuthTokenOperation object fetches a web authentication token given an API token that you obtain from CloudKit Dashboard. Use the addOperation: method in the CKDatabase class to add this operation to the operation queue of the public database.

CKLocationSortDescriptor

A CKLocationSortDescriptor object sorts records containing location data based on their distance from a location that you specify. You can add a location sort descriptor to your queries when searching for records. At creation time, you must provide the sort descriptor with a key whose value is a CLLocation object. The sort descriptor uses the value of that key to perform the sort.

CKMarkNotificationsReadOperation

A CKMarkNotificationsReadOperation object marks push notifications as read by your app so that they do not show up in future fetch results. If your app uses push notifications to track changes to records, you can use this operation object to note which push notifications do not need to be processed again.

CKModifyBadgeOperation

A CKModifyBadgeOperation object updates the badge value applied to the app’s icon. This operation object can update the badge for the current device or for all of the user’s devices.

CKModifyRecordsOperation

A CKModifyRecordsOperation object saves changes to one or more CKRecord objects. After modifying the fields of a record, use this type of operation object to save those changes to a database. You also use instances of this class to delete records permanently from a database.

CKModifyRecordZonesOperation

A CKModifyRecordZonesOperation object saves or deletes record zones. After creating one or more record zones, use this operation object to save those zones to the database. You can also use it to delete existing zones and the records they contain.

CKModifySubscriptionsOperation

A CKModifySubscriptionsOperation object saves changes to one or more CKSubscription objects. After creating or changing the configuration of a subscription object, use this type of operation object to save those changes to an iCloud container. You also use instances of this class to delete subscriptions permanently from a database.

CKNotification

A CKNotification object represents a push notification that was sent to your app. Notification objects wrap the data associated with a push notification. Use notification objects to wrap recently received push notification data or to fetch notification objects representing already delivered push notifications from a container. In both cases, the information in the notification object tells you what changed.

CKNotificationID

A CKNotificationID object uniquely identifies a push notification sent from a container. You do not create notification IDs directly. The server creates them when it creates the CKNotification objects that correspond to the push notifications sent to your app. You can compare two IDs using the isEqual: method to determine if two notification objects are the same. This class defines no methods or properties.

CKNotificationInfo

A CKNotificationInfo object specifies the push notification data that the server sends to your app when a subscription finds a match. When configuring a CKSubscription object, create one of these objects and use it to specify the type of push notifications you want generated when the subscription’s trigger condition is met. You can provide a message for an alert panel, information about the sounds to play, and information about whether the app should be badged. You can also ask the server to provide information about the record that triggered the notification.

CKOperation

The abstract base class for all operations that can be executed against a CloudKit database.

CKQuery

A CKQuery object manages the criteria to apply when searching for records in a database. You create a query object as the first step in the search process. The query object stores the search parameters, including the type of records to search, the match criteria (predicate) to apply, and the sort parameters to apply to the results. The second step is to use the query object to initialize a CKQueryOperation object, which you then execute to generate the results.

CKQueryCursor

A CKQueryCursor object is an opaque data object that marks the stopping point for a query and the starting point for retrieving the remaining results. You do not create instances of this class yourself. When fetching records using a CKQueryOperation object, if the number of results exceeds the results limit value set for the query, the server provides you with a query cursor object. Use that cursor object to initialize a new CKQueryOperation and retrieve the next batch of results for the same query.

CKQueryNotification

A CKQueryNotification object represents a push notification that was generated by a subscription object. Subscription objects represent persistent queries on the server. When the server detects a change related to a subscription, it sends a push notification to the client that created the subscription and logs the push notification in the container. You use instances of this class to get information about the record involved in the push notification.

CKQueryOperation

A CKQueryOperation object is a concrete operation that you can use to execute queries against a database. A query operation takes the query parameters you provide and applies those parameters to the specified database and zone, delivering any matching records asynchronously to the blocks that you provide.

CKQuerySubscription

Subscription that fires whenever a change matches the specified predicate.

CKRecord

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

CKRecordID

A CKRecordID object uniquely identifies a record in a database. Record ID objects are normally created automatically when you create a new record, but you might also create IDs in several specific situations. For example, you must create record ID objects when you want to save a record in a zone other than the default zone. You can also create record ID objects when you want to retrieve records whose IDs you know from a database.

CKRecordZone

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

CKRecordZoneID

A CKRecordZoneID object uniquely identifies a record zone in a database. 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.

CKRecordZoneNotification

A notification that is caused by changes to the contents of a record zone.

CKRecordZoneSubscription

A subscription that causes a push notification to fire whenever any change happens in the specified record zone.

CKReference

A CKReference object creates a many-to-one relationship between records in your database. Each reference object stores information about the one record that is the target of the reference. You then save the reference object in the fields of one or more records to create a link from those records to the target. Both records must be located in the same zone of the same database.

CKServerChangeToken

A CKServerChangeToken object is an opaque data object that identifies a specific version of a record. You do not create instances of this class yourself. When fetching records using a CKFetchRecordChangesOperation object, the server provides one of these objects along with the record changes. The next time you fetch the records, pass the previous token to the server. Passing the previous token tells the server what portions of the records to fetch and return to your app.

CKShare

A reference to a shared record.

CKShareMetadata

A reference to the metadata for a shared record.

CKShareParticipant

A reference to a person who accepted a shared record.

CKSubscription

Use a CKSubscription object to track changes occurring on the server. A subscription acts like a persistent query on the server that can track the creation, deletion, and modification of records. When changes occur, they trigger the delivery of push notifications so that your app can respond appropriately.

CKUserIdentity

A reference to a user.

CKUserIdentityLookupInfo

An object that represents information you use to fetch users.

Protocols

CKRecordValue

The CKRecordValue protocol provides strong type checking for objects that the CloudKit framework stores on the server. Do not adopt this protocol in your custom classes. CloudKit does not support writing custom data types to the server. Attempting to do so results in an error.

See Also

Related Documentation