Next Page > Hide TOC

NSCompoundPredicate Class Reference

Inherits from
Conforms to
Framework
/System/Library/Frameworks/Foundation.framework
Availability
Available in Mac OS X v10.4 and later.
Companion guide
Declared in
NSCompoundPredicate.h
Related sample code

Overview

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

Comparison operations are based on two expressions, as represented by instances of the NSExpression class. Expressions are created for constant values, key paths, and so on.

On Mac OS X v10.5 and later, NSCompoundPredicate allows you to create an AND or OR compound predicate (but not a NOT compound predicate) using an array with 0,1, or more elements. A compound predicate with 0 elements evaluates to TRUE, and a compound predicate with a single sub-predicate evaluates to the truth of its sole subpredicate.

Tasks

Constructors

Getting Information About a Compound Predicate

Class Methods

andPredicateWithSubpredicates:

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

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

Parameters
subpredicates

An array of NSPredicate objects.

Return Value

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

Availability
Related Sample Code
Declared In
NSCompoundPredicate.h

notPredicateWithSubpredicate:

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

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

Parameters
predicate

A predicate.

Return Value

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

Availability
Declared In
NSCompoundPredicate.h

orPredicateWithSubpredicates:

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

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

Parameters
subpredicates

An array of NSPredicate objects.

Return Value

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

Availability
Related Sample Code
Declared In
NSCompoundPredicate.h

Instance Methods

compoundPredicateType

Returns the predicate type for the receiver.

- (NSCompoundPredicateType)compoundPredicateType

Return Value

The predicate type for the receiver.

Availability
Declared In
NSCompoundPredicate.h

initWithType:subpredicates:

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

- (id)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.

Availability
Related Sample Code
Declared In
NSCompoundPredicate.h

subpredicates

Returns the array of the receiver’s subpredicates.

- (NSArray *)subpredicates

Return Value

The array of the receiver’s subpredicates.

Availability
Declared In
NSCompoundPredicate.h

Constants

Compound Predicate Types

These constants describe the possible types of NSCompoundPredicate.

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

Constants
NSNotPredicateType

A logical NOT predicate.

Available in Mac OS X v10.4 and later.

Declared in NSCompoundPredicate.h.

NSAndPredicateType

A logical AND predicate.

Available in Mac OS X v10.4 and later.

Declared in NSCompoundPredicate.h.

NSOrPredicateType

A logical OR predicate.

Available in Mac OS X v10.4 and later.

Declared in NSCompoundPredicate.h.

Declared In
NSCompoundPredicate.h

Next Page > Hide TOC


© 2006 Apple Computer, Inc. All Rights Reserved. (Last updated: 2006-07-04)


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.