mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-03-24 02:11:12 +01:00
WIP: segfault
This commit is contained in:
@@ -66,7 +66,7 @@ public final class SynchronousDataTransaction: BaseDataTransaction {
|
||||
- parameter closure: the block where creates, updates, and deletes can be made to the transaction. Transaction blocks are executed serially in a background queue, and all changes are made from a concurrent `NSManagedObjectContext`.
|
||||
- returns: a `SaveResult` value indicating success or failure, or `nil` if the transaction was not comitted synchronously
|
||||
*/
|
||||
public func beginSynchronous(closure: (transaction: SynchronousDataTransaction) -> Void) -> SaveResult? {
|
||||
public func beginSynchronous(_ closure: (transaction: SynchronousDataTransaction) -> Void) -> SaveResult? {
|
||||
|
||||
CoreStore.assert(
|
||||
self.transactionQueue.isCurrentExecutionContext(),
|
||||
@@ -92,7 +92,7 @@ public final class SynchronousDataTransaction: BaseDataTransaction {
|
||||
- parameter into: the `Into` clause indicating the destination `NSManagedObject` entity type and the destination configuration
|
||||
- returns: a new `NSManagedObject` instance of the specified entity type.
|
||||
*/
|
||||
public override func create<T: NSManagedObject>(into: Into<T>) -> T {
|
||||
public override func create<T: NSManagedObject>(_ into: Into<T>) -> T {
|
||||
|
||||
CoreStore.assert(
|
||||
!self.isCommitted,
|
||||
@@ -109,7 +109,7 @@ public final class SynchronousDataTransaction: BaseDataTransaction {
|
||||
- returns: an editable proxy for the specified `NSManagedObject`.
|
||||
*/
|
||||
@warn_unused_result
|
||||
public override func edit<T: NSManagedObject>(object: T?) -> T? {
|
||||
public override func edit<T: NSManagedObject>(_ object: T?) -> T? {
|
||||
|
||||
CoreStore.assert(
|
||||
!self.isCommitted,
|
||||
@@ -127,7 +127,7 @@ public final class SynchronousDataTransaction: BaseDataTransaction {
|
||||
- returns: an editable proxy for the specified `NSManagedObject`.
|
||||
*/
|
||||
@warn_unused_result
|
||||
public override func edit<T: NSManagedObject>(into: Into<T>, _ objectID: NSManagedObjectID) -> T? {
|
||||
public override func edit<T: NSManagedObject>(_ into: Into<T>, _ objectID: NSManagedObjectID) -> T? {
|
||||
|
||||
CoreStore.assert(
|
||||
!self.isCommitted,
|
||||
@@ -142,7 +142,7 @@ public final class SynchronousDataTransaction: BaseDataTransaction {
|
||||
|
||||
- parameter object: the `NSManagedObject` type to be deleted
|
||||
*/
|
||||
public override func delete(object: NSManagedObject?) {
|
||||
public override func delete(_ object: NSManagedObject?) {
|
||||
|
||||
CoreStore.assert(
|
||||
!self.isCommitted,
|
||||
@@ -159,7 +159,7 @@ public final class SynchronousDataTransaction: BaseDataTransaction {
|
||||
- parameter object2: another `NSManagedObject` to be deleted
|
||||
- parameter objects: other `NSManagedObject`s to be deleted
|
||||
*/
|
||||
public override func delete(object1: NSManagedObject?, _ object2: NSManagedObject?, _ objects: NSManagedObject?...) {
|
||||
public override func delete(_ object1: NSManagedObject?, _ object2: NSManagedObject?, _ objects: NSManagedObject?...) {
|
||||
|
||||
CoreStore.assert(
|
||||
!self.isCommitted,
|
||||
@@ -174,7 +174,7 @@ public final class SynchronousDataTransaction: BaseDataTransaction {
|
||||
|
||||
- parameter objects: the `NSManagedObject`s to be deleted
|
||||
*/
|
||||
public override func delete<S: SequenceType where S.Generator.Element: NSManagedObject>(objects: S) {
|
||||
public override func delete<S: Sequence where S.Iterator.Element: NSManagedObject>(_ objects: S) {
|
||||
|
||||
CoreStore.assert(
|
||||
!self.isCommitted,
|
||||
@@ -203,7 +203,7 @@ public final class SynchronousDataTransaction: BaseDataTransaction {
|
||||
if !self.isCommitted && self.hasChanges {
|
||||
|
||||
CoreStore.log(
|
||||
.Warning,
|
||||
.warning,
|
||||
message: "The closure for the \(cs_typeName(self)) completed without being committed. All changes made within the transaction were discarded."
|
||||
)
|
||||
}
|
||||
@@ -215,28 +215,4 @@ public final class SynchronousDataTransaction: BaseDataTransaction {
|
||||
// MARK: Private
|
||||
|
||||
private let closure: (transaction: SynchronousDataTransaction) -> Void
|
||||
|
||||
|
||||
// MARK: Deprecated
|
||||
|
||||
@available(*, deprecated=1.3.4, obsoleted=2.0.0, message="Resetting the context is inherently unsafe. This method will be removed in the near future. Use `beginUnsafe()` to create transactions with `undo` support.")
|
||||
public func rollback() {
|
||||
|
||||
CoreStore.assert(
|
||||
!self.isCommitted,
|
||||
"Attempted to rollback an already committed \(cs_typeName(self))."
|
||||
)
|
||||
CoreStore.assert(
|
||||
self.transactionQueue.isCurrentExecutionContext(),
|
||||
"Attempted to rollback a \(cs_typeName(self)) outside its designated queue."
|
||||
)
|
||||
|
||||
self.context.reset()
|
||||
}
|
||||
|
||||
@available(*, deprecated=1.5.2, obsoleted=2.0.0, renamed="commitAndWait")
|
||||
public func commit() {
|
||||
|
||||
self.commitAndWait()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user