Scope: filter with IN operator

I have an array of integers:

▿ 2 elements
  - [0] : 123459
  - [1] : 1031020

And I would like to filter my objects based on an array.

.filter("code IN \(myCodeArray)")

But this leads to a failure. How to use the IN operator?

+4
source share
1 answer

Instead of using string interpolation of strings, you should use support for argument substitution NSPredicatethrough %@:

.filter("code IN %@", myCodeArray)

Swift ("\(someVariable)") . [123459, 1031020], NSPredicate. %@ , , Swift NSPredicate.

+8

All Articles