Instance Property

predicate

The matching criteria to apply to records.

Declaration

@NSCopying var predicate: NSPredicate? { get }

Discussion

A query-based subscription uses its search predicate to identify potential matches for records. It combines the predicate information with the value in the subscriptionOptions property to determine the conditions under which to send a push notification to the app.

The search predicate defines the records that the subscription object monitors for changes. The value in this property is used only if the subscriptionType property is set to CKSubscription.SubscriptionType.query; otherwise, it is ignored.

A query-based subscription can be used to observe multiple records or a single record. An example of subscribing to the changes of a single record is shown below:

let predicate = NSPredicate(format: "recordID = %@", recordID)
let options: CKQuerySubscriptionOptions = [.firesOnRecordUpdate, .firesOnRecordDeletion]
let subscription = CKQuerySubscription(recordType: "Employee", predicate: predicate, options: options)

See Also

Accessing the Subscription Search Parameters

var zoneID: CKRecordZone.ID?

The ID of the record zone to monitor.

Deprecated