NSPredicate with dynamic key and value

前端 未结 2 749
心在旅途
心在旅途 2021-01-17 17:20

I am trying to create a function that searches through my core data stack and return the amount of messages for a desired key/value.

Here is my code:



        
2条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-17 17:43

     let predicate = NSPredicate(format: "SELF[%@] CONTAINS %@",key,value)
    

    This worked for me

提交回复
热议问题