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

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -