---
title: "registeredObject(for:)"
framework: coredata
role: symbol
role_heading: Instance Method
path: "coredata/nsmanagedobjectcontext/registeredobject(for:)"
---

# registeredObject(for:)

Returns an object that exists in the context.

## Declaration

```swift
func registeredObject(for objectID: NSManagedObjectID) -> NSManagedObject?
```

## Parameters

- `objectID`: The identifier of the object to retrieve. For more information, see doc://com.apple.coredata/documentation/CoreData/NSManagedObjectID.

## Return Value

Return Value The identified object, if it’s known to the context; otherwise, nil.

## Discussion

Discussion This method provides a convenient way to retrieve an object from the context’s registeredObjects property. A nil return value means the context doesn’t recognize the specified object; the object might still exist in the persistent store. If you need to query both the context and the store, use existingObject(with:) instead.

## 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)
- [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)
