<!--
{
  "availability" : [
    "iOS: 3.0.0 -",
    "iPadOS: 3.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.5.0 -",
    "tvOS: -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreData",
  "identifier" : "/documentation/CoreData/NSFetchRequestExpression",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Core Data"
    ],
    "preciseIdentifier" : "c:objc(cs)NSFetchRequestExpression"
  },
  "title" : "NSFetchRequestExpression"
}
-->

# NSFetchRequestExpression

An expression that evaluates the result of a fetch request on a managed object context.

```
class NSFetchRequestExpression
```

## Overview

`NSFetchRequestExpression` inherits from <doc://com.apple.documentation/documentation/Foundation/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 <doc://com.apple.documentation/documentation/Swift/true>.

## Topics

### Creating a Fetch Request Expression

[`+  expressionForFetch:context:countOnly:`](/documentation/CoreData/NSFetchRequestExpression/expression(forFetch:context:countOnly:))

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

### Examining a Fetch Request Expression

[`requestExpression`](/documentation/CoreData/NSFetchRequestExpression/requestExpression)

The expression for the receiver’s fetch request.

[`contextExpression`](/documentation/CoreData/NSFetchRequestExpression/contextExpression)

The expression for the receiver’s managed object context.

[`countOnlyRequest`](/documentation/CoreData/NSFetchRequestExpression/isCountOnlyRequest)

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

### Constants

[`NSFetchRequestExpressionType`](/documentation/CoreData/NSFetchRequestExpressionType)

This constant specifies the fetch request expression type.

## Relationships

### Inherits From

[`NSExpression`](/documentation/Foundation/NSExpression)

### Conforms To

[`NSSecureCoding`](/documentation/Foundation/NSSecureCoding)

[`Sendable`](/documentation/Swift/Sendable)

[`NSCopying`](/documentation/Foundation/NSCopying)

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

[`Hashable`](/documentation/Swift/Hashable)

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

[`Equatable`](/documentation/Swift/Equatable)

[`CVarArg`](/documentation/Swift/CVarArg)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

[`NSCoding`](/documentation/Foundation/NSCoding)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)