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

javascript - Confirm a form & display message if form is valid with JQuery -

Retrieving ETA (estimated time of arrival) with Google Distance Matrix API and public transit as transport mode -

ionic framework - Meteor - Error: Failed to execute 'insertBefore' on 'Node' -