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

'hasOwnProperty' in javascript -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -

How to understand 2 main() functions after using uftrace to profile the C++ program? -