iOS Developer Library

Developer

Foundation Framework Reference NSComparisonPredicate Class Reference

Options
Deployment Target:

On This Page
Language:

NSComparisonPredicate

NSComparisonPredicate is a subclass of NSPredicate that you use to compare expressions. More...

Inheritance


Import Statement


import Foundation @import Foundation;

Availability


Available in iOS 3.0 and later.

Data Types

  • These constants describe the possible types of modifier for NSComparisonPredicate.

    Declaration

    Swift

    enum NSComparisonPredicateModifier : UInt { case DirectPredicateModifier case AllPredicateModifier case AnyPredicateModifier }

    Objective-C

    enum { NSDirectPredicateModifier = 0, NSAllPredicateModifier, NSAnyPredicateModifier, }; typedef NSUInteger NSComparisonPredicateModifier;

    Constants

    • DirectPredicateModifier

      NSDirectPredicateModifier

      A predicate to compare directly the left and right hand sides.

      Available in iOS 3.0 and later.

    • AllPredicateModifier

      NSAllPredicateModifier

      A predicate to compare all entries in the destination of a to-many relationship.

      The left hand side must be a collection. The corresponding predicate compares each value in the left hand side with the right hand side, and returns NOfalse when it finds the first mismatch—€”or YEStrue if all match.

      Available in iOS 3.0 and later.

    • AnyPredicateModifier

      NSAnyPredicateModifier

      A predicate to match with any entry in the destination of a to-many relationship.

      The left hand side must be a collection. The corresponding predicate compares each value in the left hand side against the right hand side and returns YEStrue when it finds the first match—or NOfalse if no match is found

      Available in iOS 3.0 and later.

    Import Statement

    import Foundation

    Availability

    Available in iOS 3.0 and later.

  • These constants describe the possible types of string comparison for NSComparisonPredicate. These options are supported for LIKE as well as all of the equality/comparison operators.

    Declaration

    Swift

    struct NSComparisonPredicateOptions : RawOptionSetType { init(_ rawValue: UInt) init(rawValue rawValue: UInt) static var CaseInsensitivePredicateOption: NSComparisonPredicateOptions { get } static var DiacriticInsensitivePredicateOption: NSComparisonPredicateOptions { get } static var NormalizedPredicateOption: NSComparisonPredicateOptions { get } }

    Objective-C

    enum { NSCaseInsensitivePredicateOption = 0x01, NSDiacriticInsensitivePredicateOption = 0x02, NSNormalizedPredicateOption = 0x04, NSLocaleSensitivePredicateOption = 0x08 }; typedef NSUInteger NSComparisonPredicateOptions;

    Constants

    • CaseInsensitivePredicateOption

      NSCaseInsensitivePredicateOption

      A case-insensitive predicate.

      You represent this option in a predicate format string using a [c] following a string operation (for example, "NeXT" like[c] "next").

      Available in iOS 3.0 and later.

    • DiacriticInsensitivePredicateOption

      NSDiacriticInsensitivePredicateOption

      A diacritic-insensitive predicate.

      You represent this option in a predicate format string using a [d] following a string operation (for example, "naïve" like[d] "naive").

      Available in iOS 3.0 and later.

    • NormalizedPredicateOption

      NSNormalizedPredicateOption

      Indicates that the strings to be compared have been preprocessed.

      This option supersedes NSCaseInsensitivePredicateOption and NSDiacriticInsensitivePredicateOption, and is intended as a performance optimization option.

      You represent this option in a predicate format string using a [n] following a string operation (for example, "WXYZlan" matches[n] ".lan").

      Available in iOS 4.0 and later.

    • NSLocaleSensitivePredicateOption

      NSLocaleSensitivePredicateOption

      Indicates that strings to be compared using <, <=, =, =>, > should be handled in a locale-aware fashion.

      You represent this option in a predicate format string using a [l] following one of the <, <=, =, =>, > operators (for example, "straße" >[l] "strasse").

    Import Statement

    import Foundation

    Availability

    Available in iOS 5.0 and later.

  • Defines the type of comparison for NSComparisonPredicate.

    Declaration

    Swift

    enum NSPredicateOperatorType : UInt { case LessThanPredicateOperatorType case LessThanOrEqualToPredicateOperatorType case GreaterThanPredicateOperatorType case GreaterThanOrEqualToPredicateOperatorType case EqualToPredicateOperatorType case NotEqualToPredicateOperatorType case MatchesPredicateOperatorType case LikePredicateOperatorType case BeginsWithPredicateOperatorType case EndsWithPredicateOperatorType case InPredicateOperatorType case CustomSelectorPredicateOperatorType case ContainsPredicateOperatorType case BetweenPredicateOperatorType }

    Objective-C

    enum { NSLessThanPredicateOperatorType = 0, NSLessThanOrEqualToPredicateOperatorType, NSGreaterThanPredicateOperatorType, NSGreaterThanOrEqualToPredicateOperatorType, NSEqualToPredicateOperatorType, NSNotEqualToPredicateOperatorType, NSMatchesPredicateOperatorType, NSLikePredicateOperatorType, NSBeginsWithPredicateOperatorType, NSEndsWithPredicateOperatorType, NSInPredicateOperatorType, NSCustomSelectorPredicateOperatorType, NSContainsPredicateOperatorType, NSBetweenPredicateOperatorType }; typedef NSUInteger NSPredicateOperatorType;

    Constants

    • LessThanPredicateOperatorType

      NSLessThanPredicateOperatorType

      A less-than predicate.

      Available in iOS 3.0 and later.

    • LessThanOrEqualToPredicateOperatorType

      NSLessThanOrEqualToPredicateOperatorType

      A less-than-or-equal-to predicate.

      Available in iOS 3.0 and later.

    • GreaterThanPredicateOperatorType

      NSGreaterThanPredicateOperatorType

      A greater-than predicate.

      Available in iOS 3.0 and later.

    • GreaterThanOrEqualToPredicateOperatorType

      NSGreaterThanOrEqualToPredicateOperatorType

      A greater-than-or-equal-to predicate.

      Available in iOS 3.0 and later.

    • EqualToPredicateOperatorType

      NSEqualToPredicateOperatorType

      An equal-to predicate.

      Available in iOS 3.0 and later.

    • NotEqualToPredicateOperatorType

      NSNotEqualToPredicateOperatorType

      A not-equal-to predicate.

      Available in iOS 3.0 and later.

    • MatchesPredicateOperatorType

      NSMatchesPredicateOperatorType

      A full regular expression matching predicate.

      Available in iOS 3.0 and later.

    • LikePredicateOperatorType

      NSLikePredicateOperatorType

      A simple subset of the MATCHES predicate, similar in behavior to SQL LIKE.

      Available in iOS 3.0 and later.

    • BeginsWithPredicateOperatorType

      NSBeginsWithPredicateOperatorType

      A begins-with predicate.

      Available in iOS 3.0 and later.

    • EndsWithPredicateOperatorType

      NSEndsWithPredicateOperatorType

      An ends-with predicate.

      Available in iOS 3.0 and later.

    • InPredicateOperatorType

      NSInPredicateOperatorType

      A predicate to determine if the left hand side is in the right hand side.

      For strings, returns YEStrue if the left hand side is a substring of the right hand side . For collections, returns YEStrue if the left hand side is in the right hand side .

      Available in iOS 3.0 and later.

    • CustomSelectorPredicateOperatorType

      NSCustomSelectorPredicateOperatorType

      A predicate that uses a custom selector that takes a single argument and returns a BOOL value.

      The selector is invoked on the left hand side with the right hand side as the argument.

      Available in iOS 3.0 and later.

    • ContainsPredicateOperatorType

      NSContainsPredicateOperatorType

      A predicate to determine if the left hand side contains the right hand side.

      Returns YEStrue if [lhs contains rhs]; the left hand side must be an NSExpression object that evaluates to a collection

      Available in iOS 3.0 and later.

    • BetweenPredicateOperatorType

      NSBetweenPredicateOperatorType

      A predicate to determine if the right hand side lies at or between bounds specified by the left hand side.

      Returns YEStrue if [lhs between rhs]; the right hand side must be an array in which the first element sets the lower bound and the second element the upper, inclusive. Comparison is performed using compare: or the class-appropriate equivalent.

      Available in iOS 3.0 and later.

    Import Statement

    import Foundation

    Availability

    Available in iOS 3.0 and later.