Generic Instance Method

fetch(_:)

Returns an array of objects that meet the criteria specified by a given fetch request.

Declaration

func fetch<T>(_ request: NSFetchRequest<T>) throws -> [T] where T : NSFetchRequestResult

See Also

Registering and Fetching Objects

func fetch(NSFetchRequest<NSFetchRequestResult>) -> [Any]

Returns an array of objects that meet the criteria specified by a given fetch request.

func count(for: NSFetchRequest<NSFetchRequestResult>) -> Int

Returns the number of objects a given fetch request would have returned if it had been passed to executeFetchRequest:error:.

func registeredObject(for: NSManagedObjectID) -> NSManagedObject?

Returns the object for a specified ID, if the object is registered with the context.

func object(with: NSManagedObjectID) -> NSManagedObject

Returns an object for a specified ID even if the object needs to be fetched.

func existingObject(with: NSManagedObjectID) -> NSManagedObject

Returns the object for the specified ID or nil if the object does not exist.

var registeredObjects: Set<NSManagedObject>

The set of objects registered with the context.

func count<T>(for: NSFetchRequest<T>) -> Int

Returns the number of objects a given fetch request would have returned.

func execute(NSPersistentStoreRequest) -> NSPersistentStoreResult

Passes a request to the persistent store without affecting the contents of the managed object context and returns a persistent store result.

func refreshAllObjects()

Refreshes all currently registered objects that are associated with this context.

var retainsRegisteredObjects: Bool

A Boolean value that indicates whether the context keeps strong references to all registered managed objects.