SynchronousDataTransaction
public final class SynchronousDataTransaction : BaseDataTransaction
The SynchronousDataTransaction
provides an interface for DynamicObject
creates, updates, and deletes. A transaction object should typically be only used from within a transaction block initiated from DataStack.beginSynchronous(_:)
, or from CoreStore.beginSynchronous(_:)
.
-
Cancels a transaction by throwing
CoreStoreError.userCancelled
.try transaction.cancel()
Important
Always use plaintry
on acancel()
call. Never usetry?
ortry!
. Usingtry?
will swallow the cancellation and the transaction will proceed to commit as normal. Usingtry!
will crash the app ascancel()
will always throw an error.Declaration
Swift
public func cancel() throws -> Never
-
Creates a new
NSManagedObject
orCoreStoreObject
with the specified entity type.Declaration
Swift
public override func create<D>(_ into: Into<D>) -> D where D : DynamicObject
Parameters
into
the
Into
clause indicating the destinationNSManagedObject
orCoreStoreObject
entity type and the destination configurationReturn Value
a new
NSManagedObject
orCoreStoreObject
instance of the specified entity type. -
Returns an editable proxy of a specified
NSManagedObject
orCoreStoreObject
.Declaration
Swift
public override func edit<D>(_ object: D?) -> D? where D : DynamicObject
Parameters
object
the
NSManagedObject
orCoreStoreObject
to be editedReturn Value
an editable proxy for the specified
NSManagedObject
orCoreStoreObject
. -
Returns an editable proxy of the object with the specified
NSManagedObjectID
.Declaration
Swift
public override func edit<D>(_ into: Into<D>, _ objectID: NSManagedObjectID) -> D? where D : DynamicObject
Parameters
into
an
Into
clause specifying the entity typeobjectID
the
NSManagedObjectID
for the object to be editedReturn Value
an editable proxy for the specified
NSManagedObject
orCoreStoreObject
. -
Deletes a specified
NSManagedObject
orCoreStoreObject
.Declaration
Swift
public override func delete<D>(_ object: D?) where D : DynamicObject
Parameters
object
the
NSManagedObject
orCoreStoreObject
type to be deleted -
Deletes the specified
DynamicObject
s.Declaration
Swift
public override func delete<D>(_ object1: D?, _ object2: D?, _ objects: D?...) where D : DynamicObject
Parameters
object1
the
DynamicObject
to be deletedobject2
another
DynamicObject
to be deletedobjects
other
DynamicObject
s to be deleted -
Deletes the specified
DynamicObject
s.Declaration
Swift
public override func delete<S>(_ objects: S) where S : Sequence, S.Element : DynamicObject
Parameters
objects
the
DynamicObject
s to be deleted
-
Declaration
Swift
public var bridgeToObjectiveC: CSSynchronousDataTransaction { get }
-
Declaration
Swift
public var debugDescription: String { get }