Questions tagged [ckquery]

CKQuery is a component of the cloudkit iOS Developer Library. A CKQuery object manages the criteria to apply when searching for records in a database.

CKQuery is a component of the cloudkit iOS Developer Library. 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.

Available in iOS 8.0 and later.

Read the official reference for further details

81 questions
23
votes
2 answers

How can I make a CKQuery without predicate?

I need to query all the record types, without any filtering. I tried two ways: let query = CKQuery(recordType: "Pm", predicate: nil) let query = CKQuery(recordType: "Pm", predicate: NSPredicate(format: "")) I got…
János
  • 32,867
  • 38
  • 193
  • 353
14
votes
5 answers

CKQuery from private zone returns only first 100 CKRecords from in CloudKit

Is there any limit to the result of a query to Cloudkit private default zone? I have no clue why I only receive first 100 records with the following query: let p = NSPredicate(format: "(type == 'entered') AND (timestamp >= %@) AND (timestamp <=…
CppChase
  • 901
  • 12
  • 25
12
votes
2 answers

How do I fetch all CloudKit Records created by the current user?

Say I have a 'Species' Record Type that contains Public Records which were created by a number of Users. Currently, my query retrieves all records of 'Species': private func fetchSpecies() { // Fetch Public Database let publicDatabase =…
Matt Mac
  • 437
  • 8
  • 22
11
votes
2 answers

Am I able to use recordID.recordName in a CKQuery?

CKQuery doc says: Key names used in predicates correspond to fields in the currently evaluated record. Key names may include the names of the record’s metadata properties such as "creationDate” or any data fields you added to the record. What else…
János
  • 32,867
  • 38
  • 193
  • 353
9
votes
2 answers

How to query CloudKit for recordID IN [CKRecordID]

My predicate wants to exclude some records that are already downloaded and available in a [CKRecordID]. Now I can query 1 CKRecordID[0], but not the [CKRecordID] array. How can I query the array? let excludeIDs: [CKRecordID] This works: let pred1 =…
Rob van den Berg
  • 800
  • 5
  • 21
8
votes
1 answer

Limit the amount of results returned in CloudKit

Is there any way to limit the amount of results that are returned in a CKQuery? In SQL, it is possible to run a query like SELECT * FROM Posts LIMIT 10,15. Is there anything like the last part of the query, LIMIT 10,15 in CloudKit? For example, I…
Jojodmo
  • 23,357
  • 13
  • 65
  • 107
8
votes
2 answers

CKQuery where predicate has reference and not field?

I need to create a CKQuery where the predicate contains a reference of a record, and not a field of the record. Like this let query = CKQuery(recordType: "OUP", predicate: NSPredicate(format: "o = %@", "FF4FB4A9-271A-4AF4-B02C-722ABF25BF44") How…
János
  • 32,867
  • 38
  • 193
  • 353
7
votes
1 answer

Filter PHAssetCollections within radius of CLLocationCoordinate2d

I'm using the Photos framework (aka PhotoKit). In my app I need to gather Moments (which are of type PHAssetCollection). PHAssetCollection has a property of CLLocation *approximateLocation. However I cannot get the NSPredicate to work when I…
VaporwareWolf
  • 10,143
  • 10
  • 54
  • 80
6
votes
1 answer

Stop disingenuine CloudKit calls?

I have a CloudKit app that has data in publicDB. This is secure data that's able to be created and read by any authorized user, but I limit that based on the querys my app makes. For example, a data object stating a relationship to user A and user…
Andrew
  • 7,693
  • 11
  • 43
  • 81
6
votes
1 answer

how to mark a record type queryable in cloud kit programmatically

Im having an issue with cloud-kit whenever I create a new CKRecordType programmatically. In the cloud kit dashboard this is the error message I get: The quick and easy fix would be to click the "Add ID Query Index" button and be done with it,…
Garret Kaye
  • 2,412
  • 4
  • 21
  • 45
6
votes
1 answer

CloudKit compound query (query with OR)

I would like to query CloudKit using OR with two fields. But I can't find a way how to do this. What I did is: NSPredicate *predicate1 = [NSPredicate predicateWithFormat:@"(creatorUserRecordID == %@)", userId]; NSPredicate *predicate2 = [NSPredicate…
Wojtek
  • 1,006
  • 11
  • 30
4
votes
1 answer

CKError when querying system field: rejected "Unknown Field 'createdAt'"

I am sorting the createdAt system field like this: query.sortDescriptors = [NSSortDescriptor(key: "createdAt", ascending: false)] and get the following error: CKError 0x1c4447fb0: "Invalid Arguments" (12/2018); server message = "Unknown field…
BfromG
  • 55
  • 5
4
votes
1 answer

Can I receive count of records corresponding to CKQuery from CloudKit?

I try to use CKQueryOperation for this: CKQueryOperation *o = [[CKQueryOperation alloc] initWithQuery:query]; [o setDesiredKeys:@[]]; But it still returns a lot of data that I don't need in this moment
AlKozin
  • 904
  • 8
  • 25
4
votes
1 answer

No NSSortDescriptor on distanceToLocation for CKQuery?

With a CloudKit CKQuery you can filter on distance (see sample). But how can you sort on distance? Like location ASC. A sort descriptor on location returns an error: query.sortDescriptors = [NSSortDescriptor(key: "distanceToLocation", ascending:…
Ward Bekker
  • 6,316
  • 9
  • 38
  • 61
3
votes
1 answer

Using Cloudkit Assets as a UIimage

I have images saved in CloudKit as an asset. There are other attributes for each record as well. I can gather the record and use the other attributes, but I'm unable to use the asset in my ImageView. I'm new to Swift programming, therefore the error…
Dustin Johnson
  • 405
  • 1
  • 4
  • 5
1
2 3 4 5 6