NSFetchRequestResult
Undocumented
-
Mechanica
The NSEntityDescription object.
Declaration
Swift
public static var entity: NSEntityDescription
-
Mechanica
The entity name.
Declaration
Swift
public static var entityName: String
-
Mechanica
Creates a
new
NSFetchRequest forself
.Declaration
Swift
public static func fetchRequest() -> NSFetchRequest<Self>
-
Mechanica
Attempts to find an object matching a predicate or creates a new one and configures it.
Declaration
Swift
public static func findOrCreate(in context: NSManagedObjectContext, where predicate: NSPredicate, with configuration: (Self) -> ()) -> Self
Parameters
context
Searched context.
predicate
Matching predicate.
configuration
Configuration closure called only when creating a new object.
Return Value
A matching object or a configured new one.
-
Mechanica
Tries to find an existing object in the context (memory) matching a predicate and if doesn’t find the object in the context, tries to load it using a fetch request (if multiple objects are found, returns the first one).
Declaration
Swift
public static func findOrFetch(in context: NSManagedObjectContext, where predicate: NSPredicate) -> Self?
Parameters
context
Searched context.
predicate
Matching predicate.
Return Value
A matching object (if any).
-
Mechanica
Performs a configurable fetch request in a context.
Declaration
Swift
public static func fetch(in context: NSManagedObjectContext, with configuration: (NSFetchRequest<Self>) -> () = { _ in }) -> [Self]
-
Mechanica
Counts the results of a configurable fetch request in a context.
Declaration
Swift
public static func count(in context: NSManagedObjectContext, for configuration: (NSFetchRequest<Self>) -> () = { _ in }) -> Int
-
Mechanica
Iterates over the context’s registeredObjects set (which contains all managed objects the context currently knows about) until it finds one that is not a fault matching a given predicate. Faulted objects are not considered to to prevent Core Data to make a round trip to the persistent store.
Declaration
Swift
public static func findMaterializedObject(in context: NSManagedObjectContext, where predicate: NSPredicate) -> Self?
-
Mechanica
Executes a fetch request where only a single object is expected as result, otherwhile a fatal error occurs.
Declaration
Swift
public static func fetchSingleObject(in context: NSManagedObjectContext, with configuration: @escaping (NSFetchRequest<Self>) -> ()) -> Self?
-
Mechanica
Tries to retrieve an object from the cache; if there’s nothing in the cache executes the fetch request and caches the result (if a single object is found). - Parameters: - context: Searched context. - cacheKey: Cache key. - configuration: Configurable fetch request. - Returns: A cached object (if any).
Declaration
Swift
public static func fetchCachedObject(in context: NSManagedObjectContext, forKey cacheKey: String, with configuration: @escaping (NSFetchRequest<Self>) -> ()) -> Self?
Parameters
context
Searched context.
cacheKey
Cache key.
configuration
Configurable fetch request.
Return Value
A cached object (if any).