NSPredicate with multiple arguments and “AND behaviour”

后端 未结 4 1509
夕颜
夕颜 2020-12-19 02:51

I have a function which fetches those objects from a particular entity that fulfill a specified criterion:

func fetchWithPredicate(entityName: String, argume         


        
4条回答
  •  佛祖请我去吃肉
    2020-12-19 03:45

    In your example the %K and %@ format tokens are replaced only by the first two items of the argument array, the other items are ignored.

    You have to provide all format tokens to be replaced in the string for example

    NSPredicate(format: "%K == %@ AND %K == %@", argumentArray:["key1", "value1", "key2", "value2"])
    

提交回复
热议问题