Skip to content

Instantly share code, notes, and snippets.

@1ec5
Last active July 11, 2016 07:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 1ec5/3d81399e11ff45ee86d482cac25a0493 to your computer and use it in GitHub Desktop.
Save 1ec5/3d81399e11ff45ee86d482cac25a0493 to your computer and use it in GitHub Desktop.
Correspondence between NSPredicate types and Mapbox Style Specification filter forms
Filter form NSPredicateOperatorType/NSCompoundPredicateType
has NSContainsPredicateOperatorType
!has NSNotPredicateType(NSContainsPredicateOperatorType)
== NSEqualToPredicateOperatorType
!= NSNotEqualToPredicateOperatorType
> NSGreaterThanPredicateOperatorType
>= NSGreaterThanOrEqualToPredicateOperatorType
< NSLessThanPredicateOperatorType
<= NSLessThanOrEqualToPredicateOperatorType
in NSInPredicateOperatorType
!in NSNotPredicateType(NSInPredicateOperatorType)
all NSAndPredicateType
any NSOrPredicateType
none NSNotPredicateType(NSOrPredicateType)

Not supported directly but could be translated:

  • NSBetweenPredicateOperatorType
  • NSNotPredicateType

Unsupported, but that’s OK because a predicate-supporting backend isn’t required to support everything:

  • NSMatchesPredicateOperatorType
  • NSLikePredicateOperatorType
  • NSBeginsWithPredicateOperatorType
  • NSEndsWithPredicateOperatorType
  • NSCustomSelectorPredicateOperatorType

Key paths in NSPredicate format strings can’t contain special characters like - or $, but you can use the %K placeholder: NSPredicate(format: "admin_level > 3 AND %K == 'Polygon'", "$type").

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment