Home Ask Login Register

Developers Planet

Your answer is one click away!

nickheck February 2016

Dont work objectsWithPredicate with operator "NOT IN"?

I need to take to get items from the array that are not in the database.I'm trying to make this predicate

NSPredicate *predicate = [NSPredicate predicateWithFormat:@"!(id IN %@)", ids]; 
return[ProductModel objectsWithPredicate:predicate];

But it returns nil, but if you use a predicate without NOT, then everything works. This is work in coredata - Predicate returns the objects are not in the database. But doesn`t work in realm.


Shehzad Ali February 2016

Try this

NSPredicate *predicate = [NSPredicate predicateWithFormat:@"NOT (id IN %@)", ids]; 
NSArray *filtered  = [ids filteredArrayUsingPredicate:predicate];

Post Status

Asked in February 2016
Viewed 2,614 times
Voted 9
Answered 1 times


Leave an answer

Quote of the day: live life