UnsafeDataTransaction
public final class UnsafeDataTransaction : BaseDataTransactionextension UnsafeDataTransaction: CustomDebugStringConvertible, CoreStoreDebugStringConvertibleThe UnsafeDataTransaction provides an interface for non-contiguous NSManagedObject or CoreStoreObject creates, updates, and deletes. This is useful for making temporary changes, such as partially filled forms. An unsafe transaction object should typically be only used from the main queue.
- 
                  
                  Saves the transaction changes asynchronously. For an UnsafeDataTransaction, multiple commits are allowed, although it is the developer’s responsibility to ensure a reasonable leeway to prevent blocking the main thread.DeclarationSwift public func commit(_ completion: @escaping (_ error: CoreStoreError?) -> Void)Parameterscompletionthe block executed after the save completes. Success or failure is reported by the optional errorargument of the block.
- 
                  
                  Saves the transaction changes and waits for completion synchronously. For an UnsafeDataTransaction, multiple commits are allowed, although it is the developer’s responsibility to ensure a reasonable leeway to prevent blocking the main thread.Throws aCoreStoreErrorvalue indicating the failure.DeclarationSwift public func commitAndWait() throws
- 
                  
                  Rolls back the transaction. DeclarationSwift public func rollback()
- 
                  
                  Undo’s the last change made to the transaction. DeclarationSwift public func undo()
- 
                  
                  Immediately flushes all pending changes to the transaction’s observers. This is useful in conjunction with ListMonitors andObjectMonitors created fromUnsafeDataTransactions used to manage temporary “scratch” data.Important Note that unlikecommit(),flush()does not propagate/save updates to theDataStackand the persistent store. However, the flushed changes will be seen by children transactions created further from the current transaction (i.e. throughtransaction.beginUnsafe())Throws an error thrown fromclosure, or an error thrown by Core Data (usually validation errors or conflict errors)DeclarationSwift public func flush()
- 
                  
                  Flushes all pending changes to the transaction’s observers at the end of the closure‘s execution. This is useful in conjunction withListMonitors andObjectMonitors created fromUnsafeDataTransactions used to manage temporary “scratch” data.Important Note that unlikecommit(),flush()does not propagate/save updates to theDataStackand the persistent store. However, the flushed changes will be seen by children transactions created further from the current transaction (i.e. throughtransaction.beginUnsafe())Throws an error thrown fromclosure, or an error thrown by Core Data (usually validation errors or conflict errors)DeclarationSwift public func flush(closure: () throws -> Void) rethrowsParametersclosurethe closure where changes can be made prior to the flush 
- 
                  
                  Redo’s the last undone change to the transaction. DeclarationSwift public func redo()
- 
                  
                  Begins a child transaction where NSManagedObjectorCoreStoreObjectcreates, updates, and deletes can be made. This is useful for making temporary changes, such as partially filled forms.DeclarationSwift public func beginUnsafe( supportsUndo: Bool = false, sourceIdentifier: Any? = nil ) -> UnsafeDataTransactionParameterssupportsUndoundo(),redo(), androllback()methods are only available when this parameter istrue, otherwise those method will raise an exception. Defaults tofalse. Note that turning on Undo support may heavily impact performance especially on iOS or watchOS where memory is limited.sourceIdentifieran optional value that identifies the source of this transaction. This identifier will be passed to the change notifications and callers can use it for custom handling that depends on the source. Return Valuean UnsafeDataTransactioninstance where creates, updates, and deletes can be made.
- 
                  
                  DeclarationSwift public var debugDescription: String { get }
- 
                  
                  Utility for creating an NSFetchedResultsControllerfrom theUnsafeDataTransaction. This is useful when anNSFetchedResultsControlleris preferred over the overhead ofListMonitors abstraction.Note It is the caller’s responsibility to call performFetch()on the createdNSFetchedResultsController.DeclarationSwift @nonobjc public func createFetchedResultsController<O>(_ from: From<O>, _ sectionBy: SectionBy<O>, _ fetchClauses: FetchClause...) -> NSFetchedResultsController<O> where O : NSManagedObjectParametersfroma Fromclause indicating the entity typesectionBya SectionByclause indicating the keyPath for the attribute to use when sorting the list into sectionsfetchClausesa series of FetchClauseinstances for fetching the object list. AcceptsWhere,OrderBy, andTweakclauses.Return Valuean NSFetchedResultsControllerthat observes theUnsafeDataTransaction
- 
                  
                  Utility for creating an NSFetchedResultsControllerfrom theUnsafeDataTransaction. This is useful when anNSFetchedResultsControlleris preferred over the overhead ofListMonitors abstraction.Note It is the caller’s responsibility to call performFetch()on the createdNSFetchedResultsController.DeclarationSwift @nonobjc public func createFetchedResultsController<O>(_ from: From<O>, _ sectionBy: SectionBy<O>, _ fetchClauses: [FetchClause]) -> NSFetchedResultsController<O> where O : NSManagedObjectParametersfroma Fromclause indicating the entity typesectionBya SectionByclause indicating the keyPath for the attribute to use when sorting the list into sectionsfetchClausesa series of FetchClauseinstances for fetching the object list. AcceptsWhere,OrderBy, andTweakclauses.Return Valuean NSFetchedResultsControllerthat observes theUnsafeDataTransaction
- 
                  
                  Utility for creating an NSFetchedResultsControllerfrom theUnsafeDataTransaction. This is useful when anNSFetchedResultsControlleris preferred over the overhead ofListMonitors abstraction.Note It is the caller’s responsibility to call performFetch()on the createdNSFetchedResultsController.DeclarationSwift @nonobjc public func createFetchedResultsController<O>(_ from: From<O>, _ fetchClauses: FetchClause...) -> NSFetchedResultsController<O> where O : NSManagedObjectParametersfroma Fromclause indicating the entity typefetchClausesa series of FetchClauseinstances for fetching the object list. AcceptsWhere,OrderBy, andTweakclauses.Return Valuean NSFetchedResultsControllerthat observes theUnsafeDataTransaction
- 
                  
                  Utility for creating an NSFetchedResultsControllerfrom theUnsafeDataTransaction. This is useful when anNSFetchedResultsControlleris preferred over the overhead ofListMonitors abstraction.Note It is the caller’s responsibility to call performFetch()on the createdNSFetchedResultsController.DeclarationSwift @nonobjc public func createFetchedResultsController<O>(_ from: From<O>, _ fetchClauses: [FetchClause]) -> NSFetchedResultsController<O> where O : NSManagedObjectParametersfroma Fromclause indicating the entity typefetchClausesa series of FetchClauseinstances for fetching the object list. AcceptsWhere,OrderBy, andTweakclauses.Return Valuean NSFetchedResultsControllerthat observes theUnsafeDataTransaction
- 
                  
                  Creates an ObjectMonitorfor the specifiedDynamicObject. MultipleObjectObservers may then register themselves to be notified when changes are made to theDynamicObject.DeclarationSwift public func monitorObject<O>(_ object: O) -> ObjectMonitor<O> where O : DynamicObjectParametersobjectthe DynamicObjectto observe changes fromReturn Valuean ObjectMonitorthat monitors changes toobject
- 
                  
                  Creates a ListMonitorfor a list ofDynamicObjects that satisfy the specified fetch clauses. MultipleListObservers may then register themselves to be notified when changes are made to the list.DeclarationSwift public func monitorList<O>(_ from: From<O>, _ fetchClauses: FetchClause...) -> ListMonitor<O> where O : DynamicObjectParametersfroma Fromclause indicating the entity typefetchClausesa series of FetchClauseinstances for fetching the object list. AcceptsWhere,OrderBy, andTweakclauses.Return Valuea ListMonitorinstance that monitors changes to the list
- 
                  
                  Creates a ListMonitorfor a list ofDynamicObjects that satisfy the specified fetch clauses. MultipleListObservers may then register themselves to be notified when changes are made to the list.DeclarationSwift public func monitorList<O>(_ from: From<O>, _ fetchClauses: [FetchClause]) -> ListMonitor<O> where O : DynamicObjectParametersfroma Fromclause indicating the entity typefetchClausesa series of FetchClauseinstances for fetching the object list. AcceptsWhere,OrderBy, andTweakclauses.Return Valuea ListMonitorinstance that monitors changes to the list
- 
                  
                  Asynchronously creates a ListMonitorfor a list ofDynamicObjects that satisfy the specifiedFetchChainableBuilderTypebuilt from a chain of clauses. SinceNSFetchedResultsControllergreedily locks the persistent store on initial fetch, you may prefer this method instead of the synchronous counterpart to avoid deadlocks while background updates/saves are being executed.transaction.monitorList( { (monitor) in self.monitor = monitor }, From<MyPersonEntity>() .where(\.age > 18) .orderBy(.ascending(\.age)) )DeclarationSwift public func monitorList<B>(_ clauseChain: B) -> ListMonitor<B.ObjectType> where B : FetchChainableBuilderTypeParameterscreateAsynchronouslythe closure that receives the created ListMonitorinstanceclauseChaina FetchChainableBuilderTypebuilt from a chain of clausesReturn Valuea ListMonitorfor a list ofDynamicObjects that satisfy the specifiedFetchChainableBuilderType
- 
                  
                  Asynchronously creates a ListMonitorfor a list ofDynamicObjects that satisfy the specified fetch clauses. MultipleListObservers may then register themselves to be notified when changes are made to the list. SinceNSFetchedResultsControllergreedily locks the persistent store on initial fetch, you may prefer this method instead of the synchronous counterpart to avoid deadlocks while background updates/saves are being executed.DeclarationSwift public func monitorList<O>(createAsynchronously: @escaping (ListMonitor<O>) -> Void, _ from: From<O>, _ fetchClauses: FetchClause...) where O : DynamicObjectParameterscreateAsynchronouslythe closure that receives the created ListMonitorinstancefroma Fromclause indicating the entity typefetchClausesa series of FetchClauseinstances for fetching the object list. AcceptsWhere,OrderBy, andTweakclauses.
- 
                  
                  Asynchronously creates a ListMonitorfor a list ofDynamicObjects that satisfy the specified fetch clauses. MultipleListObservers may then register themselves to be notified when changes are made to the list. SinceNSFetchedResultsControllergreedily locks the persistent store on initial fetch, you may prefer this method instead of the synchronous counterpart to avoid deadlocks while background updates/saves are being executed.DeclarationSwift public func monitorList<O>(createAsynchronously: @escaping (ListMonitor<O>) -> Void, _ from: From<O>, _ fetchClauses: [FetchClause]) where O : DynamicObjectParameterscreateAsynchronouslythe closure that receives the created ListMonitorinstancefroma Fromclause indicating the entity typefetchClausesa series of FetchClauseinstances for fetching the object list. AcceptsWhere,OrderBy, andTweakclauses.
- 
                  
                  Asynchronously creates a ListMonitorfor a list ofDynamicObjects that satisfy the specifiedFetchChainableBuilderTypebuilt from a chain of clauses. SinceNSFetchedResultsControllergreedily locks the persistent store on initial fetch, you may prefer this method instead of the synchronous counterpart to avoid deadlocks while background updates/saves are being executed.dataStack.monitorList( createAsynchronously: { (monitor) in self.monitor = monitor }, From<MyPersonEntity>() .where(\.age > 18) .orderBy(.ascending(\.age)) )DeclarationSwift public func monitorList<B>(createAsynchronously: @escaping (ListMonitor<B.ObjectType>) -> Void, _ clauseChain: B) where B : FetchChainableBuilderTypeParameterscreateAsynchronouslythe closure that receives the created ListMonitorinstanceclauseChaina FetchChainableBuilderTypebuilt from a chain of clauses
- 
                  
                  Creates a ListMonitorfor a sectioned list ofDynamicObjects that satisfy the specified fetch clauses. MultipleListObservers may then register themselves to be notified when changes are made to the list.DeclarationSwift public func monitorSectionedList<O>(_ from: From<O>, _ sectionBy: SectionBy<O>, _ fetchClauses: FetchClause...) -> ListMonitor<O> where O : DynamicObjectParametersfroma Fromclause indicating the entity typesectionBya SectionByclause indicating the keyPath for the attribute to use when sorting the list into sections.fetchClausesa series of FetchClauseinstances for fetching the object list. AcceptsWhere,OrderBy, andTweakclauses.Return Valuea ListMonitorinstance that monitors changes to the list
- 
                  
                  Creates a ListMonitorfor a sectioned list ofDynamicObjects that satisfy the specified fetch clauses. MultipleListObservers may then register themselves to be notified when changes are made to the list.DeclarationSwift public func monitorSectionedList<O>(_ from: From<O>, _ sectionBy: SectionBy<O>, _ fetchClauses: [FetchClause]) -> ListMonitor<O> where O : DynamicObjectParametersfroma Fromclause indicating the entity typesectionBya SectionByclause indicating the keyPath for the attribute to use when sorting the list into sections.fetchClausesa series of FetchClauseinstances for fetching the object list. AcceptsWhere,OrderBy, andTweakclauses.Return Valuea ListMonitorinstance that monitors changes to the list
- 
                  
                  Creates a ListMonitorfor a sectioned list ofDynamicObjects that satisfy the specifiedSectionMonitorBuilderTypebuilt from a chain of clauses.let monitor = transaction.monitorSectionedList( From<MyPersonEntity>() .sectionBy(\.age, { "\($0!) years old" }) .where(\.age > 18) .orderBy(.ascending(\.age)) )DeclarationSwift public func monitorSectionedList<B>(_ clauseChain: B) -> ListMonitor<B.ObjectType> where B : SectionMonitorBuilderTypeParametersclauseChaina SectionMonitorBuilderTypebuilt from a chain of clausesReturn Valuea ListMonitorfor a list ofDynamicObjects that satisfy the specifiedSectionMonitorBuilderType
- 
                  
                  Asynchronously creates a ListMonitorfor a sectioned list ofDynamicObjects that satisfy the specified fetch clauses. MultipleListObservers may then register themselves to be notified when changes are made to the list. SinceNSFetchedResultsControllergreedily locks the persistent store on initial fetch, you may prefer this method instead of the synchronous counterpart to avoid deadlocks while background updates/saves are being executed.DeclarationSwift public func monitorSectionedList<O>(createAsynchronously: @escaping (ListMonitor<O>) -> Void, _ from: From<O>, _ sectionBy: SectionBy<O>, _ fetchClauses: FetchClause...) where O : DynamicObjectParameterscreateAsynchronouslythe closure that receives the created ListMonitorinstancefroma Fromclause indicating the entity typesectionBya SectionByclause indicating the keyPath for the attribute to use when sorting the list into sections.fetchClausesa series of FetchClauseinstances for fetching the object list. AcceptsWhere,OrderBy, andTweakclauses.
- 
                  
                  Asynchronously creates a ListMonitorfor a sectioned list ofDynamicObjects that satisfy the specified fetch clauses. MultipleListObservers may then register themselves to be notified when changes are made to the list. SinceNSFetchedResultsControllergreedily locks the persistent store on initial fetch, you may prefer this method instead of the synchronous counterpart to avoid deadlocks while background updates/saves are being executed.DeclarationSwift public func monitorSectionedList<O>(createAsynchronously: @escaping (ListMonitor<O>) -> Void, _ from: From<O>, _ sectionBy: SectionBy<O>, _ fetchClauses: [FetchClause]) where O : DynamicObjectParameterscreateAsynchronouslythe closure that receives the created ListMonitorinstancefroma Fromclause indicating the entity typesectionBya SectionByclause indicating the keyPath for the attribute to use when sorting the list into sections.fetchClausesa series of FetchClauseinstances for fetching the object list. AcceptsWhere,OrderBy, andTweakclauses.
- 
                  
                  Asynchronously creates a ListMonitorfor a sectioned list ofDynamicObjects that satisfy the specifiedSectionMonitorBuilderTypebuilt from a chain of clauses.transaction.monitorSectionedList( { (monitor) in self.monitor = monitor }, From<MyPersonEntity>() .sectionBy(\.age, { "\($0!) years old" }) .where(\.age > 18) .orderBy(.ascending(\.age)) )DeclarationSwift public func monitorSectionedList<B>(createAsynchronously: @escaping (ListMonitor<B.ObjectType>) -> Void, _ clauseChain: B) where B : SectionMonitorBuilderTypeParameterscreateAsynchronouslythe closure that receives the created ListMonitorinstanceclauseChaina SectionMonitorBuilderTypebuilt from a chain of clauses
 View on GitHub
            View on GitHub
           UnsafeDataTransaction Class Reference
      UnsafeDataTransaction Class Reference