Query for objects (NOT) contained in my array

I have an NSArray (iOS) of previously downloaded data objects. I would like to query for similar objects but not contained in this array. How can I do it ?

Hi Bartek,

That should be easy. Here’s the where clause query you could run:

objectId not in (‘existingObjectId1’, ‘existingObjectId2’, ‘existingObjectId3’ )

where existingObjectId1, existingObjectId2, existingObjectId3 are objectId values for the objects you downloaded.

Regards,
Mark

Hi,
Thank You for a quick response.

So I have to make a string with elements of the array explicitely counted ?
Can’t I just do :
query.whereClause = [NSString stringWithFormat: @“objectId not in %@”, myArray];
??

If that approach results in the same string, then it should be fine (make sure to put all the objectId values into parenthesis and each value must be surrounded by single quotes - they are strings and syntax requires the string values to be designed as such).

Ok I’ll try it then. Thank you very much :slight_smile:

It is my first question here and I’m impressed with how rapid the answer was!