---
title: "count(for:)"
framework: coredata
role: symbol
role_heading: Instance Method
path: "coredata/nsmanagedobjectcontext/count(for:)-93zbm"
---

# count(for:)

Returns the number of objects the specified request fetches when it executes.

## Declaration

```swift
func count(for request: NSFetchRequest<any NSFetchRequestResult>) throws -> Int
```

## Parameters

- `request`: A fetch request that specifies the search criteria for the fetch.

## Return Value

Return Value The number of objects a given fetch request would have returned if it had been passed to fetch(_:), or NSNotFound if an error occurs.

## See Also

### Registering and fetching objects

- [fetch(_:)](coredata/nsmanagedobjectcontext/fetch(_:)-38ys1.md)
- [fetch(_:)](coredata/nsmanagedobjectcontext/fetch(_:)-4xeoz.md)
- [registeredObject(for:)](coredata/nsmanagedobjectcontext/registeredobject(for:).md)
- [object(with:)](coredata/nsmanagedobjectcontext/object(with:).md)
- [existingObject(with:)](coredata/nsmanagedobjectcontext/existingobject(with:).md)
- [registeredObjects](coredata/nsmanagedobjectcontext/registeredobjects.md)
- [count(for:)](coredata/nsmanagedobjectcontext/count(for:)-3r91z.md)
- [execute(_:)](coredata/nsmanagedobjectcontext/execute(_:).md)
- [refreshAllObjects()](coredata/nsmanagedobjectcontext/refreshallobjects().md)
- [retainsRegisteredObjects](coredata/nsmanagedobjectcontext/retainsregisteredobjects.md)
