<!--
{
  "availability" : [
    "iOS: 3.0.0 -",
    "iPadOS: 3.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.6.0 -",
    "tvOS: -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreData",
  "identifier" : "/documentation/CoreData/NSManagedObjectContext/existingObject(with:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Core Data"
    ],
    "preciseIdentifier" : "c:objc(cs)NSManagedObjectContext(im)existingObjectWithID:error:"
  },
  "title" : "existingObject(with:)"
}
-->

# existingObject(with:)

Returns an existing object from either the context or the persistent store.

```
func existingObject(with objectID: NSManagedObjectID) throws -> NSManagedObject
```

## Parameters

`objectID`

The identifier of the object to retrieve. For more information, see [`NSManagedObjectID`](/documentation/CoreData/NSManagedObjectID).

## Return Value

The identified object from either the context or the persistent store.

## Discussion

If the context recognizes the specified object, the method returns that object. Otherwise, the context fetches and returns a fully realized object from the persistent store; unlike [`object(with:)`](/documentation/CoreData/NSManagedObjectContext/object(with:)), this method never returns a fault. If the object doesn’t exist in both the context and the persistent store, the method throws an error.

---

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)