NSManagedObjectContext
-
Mechanica
Caches a NSManagedObject
object
for akey
in this context.Note
The NSManagedObjectobject
must have the same NSManagedObjectContext ofself
otherwise it will be not cached.Declaration
Swift
public final func setCachedManagedObject(_ object: NSManagedObject?, forKey key: String)
-
Mechanica
Returns a cached NSManagedObject
object
in this context for a givenkey
.Declaration
Swift
public final func cachedManagedObject(forKey key: String) -> NSManagedObject?
-
Mechanica
Clears all cached NSManagedObject objects in this context.
Declaration
Swift
public final func clearCachedManagedObjects()
-
Mechanica
The persistent stores associated with the receiver.
Declaration
Swift
public final var persistentStores: [NSPersistentStore]
-
Mechanica
Returns a dictionary that contains the metadata currently stored or to-be-stored in a given persistent store.
Declaration
Swift
public final func metaData(for store: NSPersistentStore) -> [String: Any]
-
Mechanica
Adds an
object
to the store’s metadata and saves it asynchronously.Declaration
Swift
public final func setMetaDataObject(_ object: Any?, with key: String, for store: NSPersistentStore, completion handler: ( (Error?) -> Void )? = nil )
Parameters
object
Object to be added to the medata dictionary.
key
Object key
store
NSPersistentStore where is stored the metadata.
handler
The completion handler called when the saving is completed.
-
Mechanica
Returns the entity with the specified name from the managed object model associated with the specified managed object context’s persistent store coordinator.
Declaration
Swift
public final func entity(forEntityName name: String) -> NSEntityDescription
-
Mechanica
Declaration
Swift
public final func newBackgroundContext(asChildContext isChildContext: Bool = false) -> NSManagedObjectContext
Parameters
asChildContext
Specifies if this new context is a child context of the current context (default false).
Return Value
a
new
backgroundNSManagedObjectContext
.
-
Mechanica
Asynchronously performs changes and then saves them or rollbacks if any error occurs.
Declaration
Swift
public final func performSave(after changes: @escaping () -> Void, completion: ( (Error?) -> Void )? = nil )
Parameters
changes
Changes to be applied in the current context before the saving operation.
completion
Block executed (on the context’s queue.) at the end of the saving operation.
-
Mechanica
Synchronously performs changes and then saves them or rollbacks if any error occurs.
Throws
An error in cases of a saving operation failure.Declaration
Swift
public final func performSaveAndWait(after changes: () -> Void) throws