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

# count(for:)

Returns a count of the objects the specified request fetches when it executes.

## Declaration

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

## See Also

### Registering and fetching objects

- [fetch(_:)](coredata/nsmanagedobjectcontext/fetch(_:)-38ys1.md)
- [fetch(_:)](coredata/nsmanagedobjectcontext/fetch(_:)-4xeoz.md)
- [count(for:)](coredata/nsmanagedobjectcontext/count(for:)-93zbm.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)
- [execute(_:)](coredata/nsmanagedobjectcontext/execute(_:).md)
- [refreshAllObjects()](coredata/nsmanagedobjectcontext/refreshallobjects().md)
- [retainsRegisteredObjects](coredata/nsmanagedobjectcontext/retainsregisteredobjects.md)
