SynchronousDataTransaction
public final class SynchronousDataTransaction : BaseDataTransaction
extension SynchronousDataTransaction: CustomDebugStringConvertible, CoreStoreDebugStringConvertible
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(_:).
-
Cancels a transaction by throwing
CoreStoreError.userCancelled.try transaction.cancel()Important
Always use plaintryon 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
NSManagedObjectorCoreStoreObjectwith the specified entity type.Declaration
Swift
public override func create<O>(_ into: Into<O>) -> O where O : DynamicObjectParameters
intothe
Intoclause indicating the destinationNSManagedObjectorCoreStoreObjectentity type and the destination configurationReturn Value
a new
NSManagedObjectorCoreStoreObjectinstance of the specified entity type. -
Returns an editable proxy of a specified
NSManagedObjectorCoreStoreObject.Declaration
Swift
public override func edit<O>(_ object: O?) -> O? where O : DynamicObjectParameters
objectthe
NSManagedObjectorCoreStoreObjectto be editedReturn Value
an editable proxy for the specified
NSManagedObjectorCoreStoreObject. -
Returns an editable proxy of the object with the specified
NSManagedObjectID.Declaration
Swift
public override func edit<O>(_ into: Into<O>, _ objectID: NSManagedObjectID) -> O? where O : DynamicObjectParameters
intoan
Intoclause specifying the entity typeobjectIDthe
NSManagedObjectIDfor the object to be editedReturn Value
an editable proxy for the specified
NSManagedObjectorCoreStoreObject. -
Deletes the objects with the specified
NSManagedObjectIDs.Declaration
Swift
public override func delete<S>(objectIDs: S) where S : Sequence, S.Element : NSManagedObjectIDParameters
objectIDsthe
NSManagedObjectIDs of the objects to delete -
Deletes the specified
NSManagedObjects orCoreStoreObjects represented by series ofObjectRepresentations.Declaration
Swift
public override func delete<O>(_ object: O?, _ objects: O?...) where O : ObjectRepresentationParameters
objectthe
ObjectRepresentationrepresenting anNSManagedObjectorCoreStoreObjectto be deletedobjectsother
ObjectRepresentations representingNSManagedObjects orCoreStoreObjects to be deleted -
Deletes the specified
NSManagedObjects orCoreStoreObjects represented by anObjectRepresenation.Declaration
Swift
public override func delete<S>(_ objects: S) where S : Sequence, S.Element : ObjectRepresentationParameters
objectsthe
ObjectRepresenations representingNSManagedObjects orCoreStoreObjects to be deleted
-
Declaration
Swift
public var debugDescription: String { get }
View on GitHub
SynchronousDataTransaction Class Reference