Mac Developer Library

Developer

Foundation Framework Reference NSCompoundPredicate Class Reference

Options
Deployment Target:

On This Page
Language:

NSCompoundPredicate

NSCompoundPredicate is a subclass of NSPredicate used to represent logical “gate” operations (AND/OR/NOT) and comparison operations. More...

Inheritance


Import Statement


import Foundation @import Foundation;

Availability


Available in OS X v10.4 and later.
  • Returns a new predicate formed by AND-ing the predicates in a given array.

    Declaration

    Swift

    class func andPredicateWithSubpredicates(_ subpredicates: [AnyObject]) -> NSCompoundPredicate

    Objective-C

    + (NSCompoundPredicate *)andPredicateWithSubpredicates:(NSArray *)subpredicates

    Parameters

    subpredicates

    An array of NSPredicate objects.

    Return Value

    A new predicate formed by AND-ing the predicates specified by subpredicates.

    Discussion

    An AND predicate with no subpredicates evaluates to TRUE.

    Special Considerations

    For applications linked on OS X v10.5 or later, the subpredicates array is copied. For applications linked on OS X v10.4, the subpredicates array is retained (for binary compatibility).

    Import Statement

    import Foundation

    Availability

    Available in OS X v10.4 and later.

  • Returns a new predicate formed by NOT-ing a given predicate.

    Declaration

    Swift

    class func notPredicateWithSubpredicate(_ predicate: NSPredicate) -> NSCompoundPredicate

    Objective-C

    + (NSCompoundPredicate *)notPredicateWithSubpredicate:(NSPredicate *)predicate

    Parameters

    predicate

    A predicate.

    Return Value

    A new predicate formed by NOT-ing the predicate specified by predicate.

    Special Considerations

    For applications linked on OS X v10.5 or later, the subpredicates array is copied. For applications linked on OS X v10.4, the subpredicates array is retained (for binary compatibility).

    Import Statement

    import Foundation

    Availability

    Available in OS X v10.4 and later.

  • Returns a new predicate formed by OR-ing the predicates in a given array.

    Declaration

    Swift

    class func orPredicateWithSubpredicates(_ subpredicates: [AnyObject]) -> NSCompoundPredicate

    Objective-C

    + (NSCompoundPredicate *)orPredicateWithSubpredicates:(NSArray *)subpredicates

    Parameters

    subpredicates

    An array of NSPredicate objects.

    Return Value

    A new predicate formed by OR-ing the predicates specified by subpredicates.

    Discussion

    An OR predicate with no subpredicates evaluates to FALSE.

    Special Considerations

    For applications linked on OS X v10.5 or later, the subpredicates array is copied. For applications linked on OS X v10.4, the subpredicates array is retained (for binary compatibility).

    Import Statement

    import Foundation

    Availability

    Available in OS X v10.4 and later.

  • Returns the receiver initialized to a given type using predicates from a given array.

    Declaration

    Swift

    init(type type: NSCompoundPredicateType, subpredicates subpredicates: [AnyObject]!)

    Objective-C

    - (instancetype)initWithType:(NSCompoundPredicateType)type subpredicates:(NSArray *)subpredicates

    Parameters

    type

    The type of the new predicate.

    subpredicates

    An array of NSPredicate objects.

    Return Value

    The receiver initialized with its type set to type and subpredicates array to subpredicates.

    Special Considerations

    For applications linked on OS X v10.5 or later, the subpredicates array is copied. For applications linked on OS X v10.4, the subpredicates array is retained (for binary compatibility).

    Import Statement

    import Foundation

    Availability

    Available in OS X v10.4 and later.

  • The predicate type for the receiver. (read-only)

    Declaration

    Swift

    var compoundPredicateType: NSCompoundPredicateType { get }

    Objective-C

    @property(readonly) NSCompoundPredicateType compoundPredicateType

    Import Statement

    import Foundation

    Availability

    Available in OS X v10.4 and later.

  • The receiver’s subpredicates. (read-only)

    Declaration

    Swift

    var subpredicates: [AnyObject] { get }

    Objective-C

    @property(readonly, copy) NSArray *subpredicates

    Import Statement

    import Foundation

    Availability

    Available in OS X v10.4 and later.

  • These constants describe the possible types of NSCompoundPredicate.

    Declaration

    Swift

    enum NSCompoundPredicateType : UInt { case NotPredicateType case AndPredicateType case OrPredicateType }

    Objective-C

    typedef enum { NSNotPredicateType = 0, NSAndPredicateType, NSOrPredicateType, } NSCompoundPredicateType;

    Constants

    • NotPredicateType

      NSNotPredicateType

      A logical NOT predicate.

      Available in OS X v10.4 and later.

    • AndPredicateType

      NSAndPredicateType

      A logical AND predicate.

      Available in OS X v10.4 and later.

    • OrPredicateType

      NSOrPredicateType

      A logical OR predicate.

      Available in OS X v10.4 and later.

    Import Statement

    import Foundation

    Availability

    Available in OS X v10.4 and later.