NSFetchRequestExpression Class Reference

Inherits from
Conforms to
Framework
/System/Library/Frameworks/CoreData.framework
Availability
Available in OS X v10.5 and later.
Declared in
NSFetchRequestExpression.h
Companion guides

Overview

Instances of NSFetchRequestExpression represent expressions which evaluate to the result of executing a fetch request on a managed object context.

NSFetchRequestExpression inherits from NSExpression, which provides most of the basic behavior. The first argument must be an expression which evaluates to an NSFetchRequest object, and the second must be an expression which evaluates to an NSManagedObjectContext object. If you simply want the count for the request, the countOnly argument should be YES.

Tasks

Creating a Fetch Request Expression

Examining a Fetch Request Expression

Class Methods

expressionForFetch:context:countOnly:

Returns an expression which will evaluate to the result of executing a fetch request on a context.

+ (NSExpression *)expressionForFetch:(NSExpression *)fetch context:(NSExpression *)context countOnly:(BOOL)countFlag
Parameters
fetch

An expression that evaluates to an instance of NSFetchRequest.

context

An expression that evaluates to an instance of NSManagedObjectContext.

countFlag

If YES, when the new expression is evaluated the managed object context (from context) will perform countForFetchRequest:error: with the fetch request (from fetch). If NO, when the new expression is evaluated the managed object context will perform executeFetchRequest:error: with the fetch request.

Return Value

An expression which will evaluate to the result of executing a fetch request (from fetch) on a managed object context (from context).

Availability
  • Available in OS X v10.5 and later.
Declared In
NSFetchRequestExpression.h

Instance Methods

contextExpression

Returns the expression for the receiver’s managed object context.

- (NSExpression *)contextExpression
Return Value

The expression for the receiver’s managed object context. Evaluating the expression must return an NSManagedObjectContext object.

Availability
  • Available in OS X v10.5 and later.
Declared In
NSFetchRequestExpression.h

isCountOnlyRequest

Returns a Boolean value that indicates whether the receiver represents a count-only fetch request.

- (BOOL)isCountOnlyRequest
Return Value

YES if the receiver represents a count-only fetch request, otherwise NO.

Discussion

If this method returns NO, the managed object context (from the contextExpression) will perform executeFetchRequest:error:: with the requestExpression; if this method returns YES, the managed object context will perform countForFetchRequest:error: with the requestExpression.

Availability
  • Available in OS X v10.5 and later.
Declared In
NSFetchRequestExpression.h

requestExpression

Returns the expression for the receiver’s fetch request.

- (NSExpression *)requestExpresson
Return Value

The expression for the receiver’s fetch request. Evaluating the expression must return an NSFetchRequest object.

Availability
  • Available in OS X v10.5 and later.
Declared In
NSFetchRequestExpression.h

Constants

Fetch request expression type

This constant specifies the fetch request expression type.

enum {
   NSFetchRequestExpressionType = 50
};
Constants
NSFetchRequestExpressionType

Specifies the fetch request expression type.

Available in OS X v10.5 and later.

Declared in NSFetchRequestExpression.h.

Declared In
NSFetchRequestExpression.h