Contents

existingObject(with:)

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

Declaration

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

Parameters

  • objectID:

    The identifier of the object to retrieve. For more information, see 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:), 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.

See Also

Registering and fetching objects