NSPredicate

Download ios eBook

Syntax

  • Predicate Format String Substitions
    • C format string specifiers: %d, %s, %f, etc
    • Object substitution: %@
    • Keypath substitution: %K
  • Predicate Comparison Operators
    • =, ==: Left-hand expression equals right-hand expression
    • >=, =>: Left-hand expression is greater than or equal to right-hand expression
    • <=, =<: Left-hand expression is less than or equal to right-hand expression
    • >: Left-hand expression is greater than right-hand expression
    • <: Left-hand expression is less than right-hand expression
    • !=, <>: Left-hand expression is not equal to right-hand expression
    • BETWEEN: Left-hand expression is between or equal to either of the values in the right-hand expression, which specifies lower and upper bounds - ex: BETWEEN { 0, 5 }
  • Predicate Compound Operators
    • AND, &&: Logical AND
    • OR, ||: Logical OR
    • NOT, !: Logical NOT
  • Predicate String Comparison Operators
    • BEGINSWITH: Left-hand expression begins with right-hand expression
    • ENDSWITH: Left-hand expression ends with right-hand expression
    • CONTAINS: Left-hand expression contains right-hand expression
    • LIKE: Left-hand expression equals right-hand expression, with wildcard substitution
      • *: Match zero or more characters
      • ?: Match one character

Related Examples

Stats

78 Contributors: 3
Friday, December 23, 2016
Licensed under: CC-BY-SA

Not affiliated with Stack Overflow
Rip Tutorial: info@zzzprojects.com

Download eBook