Reputation: 7772
I want to show all items where value1
contains value2
. I tried this:
let fetchRequest = NSFetchRequest(entityName: "Product")
fetchRequest.predicate = NSPredicate(format: "value1 CONTAINS[cd] value2")
value1
, value2
- current object values, it is not variables
But i got error:
Unable to parse the format string
Why it doesn't allow me to do this ?
Upvotes: 2
Views: 965
Reputation: 15512
Try to use this predicate:
let predicate = NSPredicate(format: "value1 CONTAINS[cd] %@", value2)
As were investigated during communication with developer. Issue is in data that is saved to the database. In his case data is saved with quotes ("") and NSPredicate(format: "value1 CONTAINS[cd] %@", value2)
is working with errors due to that issue.
Upvotes: 3