---
title: "fetchCount(_:)"
framework: swiftdata
role: symbol
role_heading: Instance Method
path: "swiftdata/modelcontext/fetchcount(_:)"
---

# fetchCount(_:)

Returns the number of models that match the criteria of the specified fetch descriptor.

## Declaration

```swift
func fetchCount<T>(_ descriptor: FetchDescriptor<T>) throws -> Int where T : PersistentModel
```

## Parameters

- `descriptor`: A fetch descriptor that provides the configuration for the fetch.

## Return Value

Return Value The total number of models that satisfy the criteria of the fetch descriptor.

## See Also

### Fetching models

- [fetch(_:)](swiftdata/modelcontext/fetch(_:).md)
- [fetch(_:batchSize:)](swiftdata/modelcontext/fetch(_:batchsize:).md)
- [FetchDescriptor](swiftdata/fetchdescriptor.md)
- [FetchResultsCollection](swiftdata/fetchresultscollection.md)
- [enumerate(_:batchSize:allowEscapingMutations:block:)](swiftdata/modelcontext/enumerate(_:batchsize:allowescapingmutations:block:).md)
- [model(for:)](swiftdata/modelcontext/model(for:).md)
- [registeredModel(for:)](swiftdata/modelcontext/registeredmodel(for:).md)
