Instance Method

initWithRecordType:predicate:

Initializes and returns a query object with the specified parameters.

Declaration

- (instancetype)initWithRecordType:(CKRecordType)recordType predicate:(NSPredicate *)predicate;

Parameters

recordType

The type of record to search. Specify the name of one of your app’s supported record types.

This method throws an exception if this parameter is nil or contains an empty string.

predicate

The search predicate to apply to the prospective records. Only records matching the predicate criteria are returned in the search results. For guidelines on how to construct predicates for your queries, see Predicate Rules for Query Objects.

This parameter must not be nil.

Return Value

An initialized query object.

Discussion

You cannot change the record type and predicate of a query object after you create it. If you want to search for a different set of records using a different set of search criteria, create a new query object. You can add sort descriptors to the query and change them later as needed.

You cannot query for user records and executing a query where the record type is set to CKRecordTypeUserRecord results in an error. You must fetch user records directly using their ID.

See Also

Initializing a Query Object