Cloudkit query array size == 0

时间:2019-03-19 14:44:12

标签: ios objective-c nspredicate cloudkit ckquery

I'm performing query operation with Cloudkit, my record type is like this:

CKRecord Type: Person
{
  name STRING,
  age  INTEGER,
  friends  ARRAY,
}

Now, I want to query all person with no friends.I have tried

NSPredicate *predicate = [[NSPredicate alloc] initWithFormat: @"friends[SIZE] == 0"];
CKQuery *query = [[CKQuery alloc] initWithPredicate: predicate];

And

NSPredicate *predicate = [[NSPredicate alloc] initWithFormat: @"friends.@count == 0"];
CKQuery *query = [[CKQuery alloc] initWithPredicate: predicate];

The first one crashed with warning

friends[SIZE] is not an evaluated object expression

and second one returning error of

Invalid predicate

So , what is the correct way to query with array size?

0 个答案:

没有答案