swift3 - NSPredicate Differences -
i have been teaching myself predicates , have situation differing behavior between 2 predicates should act same.
this first case works correctly, returning items:
let wordpredicate = nspredicate(format: "name contains[cd] 'word'") (items nsarray).filtered(using: wordpredicate)
bet second case not return anything:
let keycontainsvarpredicate = nspredicate(format: "$key contains[cd] '$word'") (items nsarray).filtered(using: keycontainsvarpredicate.withsubstitutionvariables(["key": "name", "word": "word"])
i figured out actually.
you cannot substitute in property name.
Comments
Post a Comment