From cdcd7d0416cd31e8b50bfe7476a7a302ca3e40a0 Mon Sep 17 00:00:00 2001 From: John Rommel Estropia Date: Sat, 1 Apr 2017 23:08:36 +0900 Subject: [PATCH] removed deprecated functions in unit tests and demo app --- ...etchingAndQueryingDemoViewController.swift | 32 ++++---- .../ListObserverDemoViewController.swift | 39 +++++----- .../ObjectObserverDemoViewController.swift | 74 ++++++++++--------- .../CustomLoggerViewController.swift | 12 ++- .../MigrationsDemoViewController.swift | 46 ++++++------ .../StackSetupDemoViewController.swift | 65 ++++++++-------- .../TransactionsDemoViewController.swift | 41 +++++----- CoreStoreTests/BridgingTests.m | 26 ++++--- .../BaseDataTransaction+Querying.swift | 2 +- .../DataStack+Querying.swift | 2 +- .../FetchableSource.swift | 2 +- .../QueryableSource.swift | 2 +- Sources/Importing/ImportableObject.swift | 4 +- .../Importing/ImportableUniqueObject.swift | 10 +-- .../NSManagedObjectContext+Querying.swift | 2 +- ...reStore+CustomDebugStringConvertible.swift | 2 +- .../CSAsynchronousDataTransaction.swift | 4 +- .../ObjectiveC/CSCoreStore+Transaction.swift | 2 +- .../ObjectiveC/CSDataStack+Transaction.swift | 2 +- Sources/ObjectiveC/CSSaveResult.swift | 4 +- .../CSSynchronousDataTransaction.swift | 4 +- .../ObjectiveC/CSUnsafeDataTransaction.swift | 6 +- Sources/Setup/CoreStore+Setup.swift | 2 +- Sources/Setup/DataStack.swift | 4 +- .../AsynchronousDataTransaction.swift | 4 +- .../Transactions/CoreStore+Transaction.swift | 4 +- .../Transactions/DataStack+Transaction.swift | 4 +- Sources/Transactions/SaveResult.swift | 2 +- .../SynchronousDataTransaction.swift | 6 +- 29 files changed, 214 insertions(+), 195 deletions(-) diff --git a/CoreStoreDemo/CoreStoreDemo/Fetching and Querying Demo/FetchingAndQueryingDemoViewController.swift b/CoreStoreDemo/CoreStoreDemo/Fetching and Querying Demo/FetchingAndQueryingDemoViewController.swift index c4aa4c0..013c529 100644 --- a/CoreStoreDemo/CoreStoreDemo/Fetching and Querying Demo/FetchingAndQueryingDemoViewController.swift +++ b/CoreStoreDemo/CoreStoreDemo/Fetching and Querying Demo/FetchingAndQueryingDemoViewController.swift @@ -22,26 +22,24 @@ private struct Static { localStorageOptions: .recreateStoreOnModelMismatch ) ) - - _ = dataStack.beginSynchronous { (transaction) -> Void in - - transaction.deleteAll(From()) - - for name in NSTimeZone.knownTimeZoneNames { + _ = try? dataStack.perform( + synchronous: { (transaction) in - let rawTimeZone = NSTimeZone(name: name)! - let cachedTimeZone = transaction.create(Into()) + transaction.deleteAll(From()) - cachedTimeZone.name = rawTimeZone.name - cachedTimeZone.abbreviation = rawTimeZone.abbreviation ?? "" - cachedTimeZone.secondsFromGMT = Int32(rawTimeZone.secondsFromGMT) - cachedTimeZone.hasDaylightSavingTime = rawTimeZone.isDaylightSavingTime - cachedTimeZone.daylightSavingTimeOffset = rawTimeZone.daylightSavingTimeOffset + for name in NSTimeZone.knownTimeZoneNames { + + let rawTimeZone = NSTimeZone(name: name)! + let cachedTimeZone = transaction.create(Into()) + + cachedTimeZone.name = rawTimeZone.name + cachedTimeZone.abbreviation = rawTimeZone.abbreviation ?? "" + cachedTimeZone.secondsFromGMT = Int32(rawTimeZone.secondsFromGMT) + cachedTimeZone.hasDaylightSavingTime = rawTimeZone.isDaylightSavingTime + cachedTimeZone.daylightSavingTimeOffset = rawTimeZone.daylightSavingTimeOffset + } } - - _ = transaction.commitAndWait() - } - + ) return dataStack }() } diff --git a/CoreStoreDemo/CoreStoreDemo/List and Object Observers Demo/ListObserverDemoViewController.swift b/CoreStoreDemo/CoreStoreDemo/List and Object Observers Demo/ListObserverDemoViewController.swift index 5a84b73..0b2d310 100644 --- a/CoreStoreDemo/CoreStoreDemo/List and Object Observers Demo/ListObserverDemoViewController.swift +++ b/CoreStoreDemo/CoreStoreDemo/List and Object Observers Demo/ListObserverDemoViewController.swift @@ -172,11 +172,13 @@ class ListObserverDemoViewController: UITableViewController, ListSectionObserver case .delete: let palette = Static.palettes[indexPath] - CoreStore.beginAsynchronous{ (transaction) -> Void in - - transaction.delete(palette) - transaction.commit { (result) -> Void in } - } + CoreStore.perform( + asynchronous: { (transaction) in + + transaction.delete(palette) + }, + completion: { _ in } + ) default: break @@ -263,11 +265,13 @@ class ListObserverDemoViewController: UITableViewController, ListSectionObserver @IBAction private dynamic func resetBarButtonItemTouched(_ sender: AnyObject?) { - CoreStore.beginAsynchronous { (transaction) -> Void in - - transaction.deleteAll(From()) - transaction.commit() - } + CoreStore.perform( + asynchronous: { (transaction) in + + transaction.deleteAll(From()) + }, + completion: { _ in } + ) } @IBAction private dynamic func filterBarButtonItemTouched(_ sender: AnyObject?) { @@ -277,13 +281,14 @@ class ListObserverDemoViewController: UITableViewController, ListSectionObserver @IBAction private dynamic func addBarButtonItemTouched(_ sender: AnyObject?) { - CoreStore.beginAsynchronous { (transaction) -> Void in - - let palette = transaction.create(Into()) - palette.setInitialValues() - - transaction.commit() - } + CoreStore.perform( + asynchronous: { (transaction) in + + let palette = transaction.create(Into()) + palette.setInitialValues() + }, + completion: { _ in } + ) } private func setTable(enabled: Bool) { diff --git a/CoreStoreDemo/CoreStoreDemo/List and Object Observers Demo/ObjectObserverDemoViewController.swift b/CoreStoreDemo/CoreStoreDemo/List and Object Observers Demo/ObjectObserverDemoViewController.swift index b887d3f..ce95fe4 100644 --- a/CoreStoreDemo/CoreStoreDemo/List and Object Observers Demo/ObjectObserverDemoViewController.swift +++ b/CoreStoreDemo/CoreStoreDemo/List and Object Observers Demo/ObjectObserverDemoViewController.swift @@ -56,13 +56,13 @@ class ObjectObserverDemoViewController: UIViewController, ObjectObserver { } else { - CoreStore.beginSynchronous { (transaction) -> Void in - - let palette = transaction.create(Into(Palette.self)) - palette.setInitialValues() - - _ = transaction.commitAndWait() - } + _ = try? CoreStore.perform( + synchronous: { (transaction) in + + let palette = transaction.create(Into(Palette.self)) + palette.setInitialValues() + } + ) let palette = CoreStore.fetchOne(From(), OrderBy(.ascending(#keyPath(Palette.hue))))! self.monitor = CoreStore.monitorObject(palette) @@ -121,49 +121,57 @@ class ObjectObserverDemoViewController: UIViewController, ObjectObserver { @IBAction dynamic func hueSliderValueDidChange(_ sender: AnyObject?) { let hue = self.hueSlider?.value ?? 0 - CoreStore.beginAsynchronous { [weak self] (transaction) -> Void in - - if let palette = transaction.edit(self?.monitor?.object) { + CoreStore.perform( + asynchronous: { [weak self] (transaction) in - palette.hue = Int32(hue) - transaction.commit() - } - } + if let palette = transaction.edit(self?.monitor?.object) { + + palette.hue = Int32(hue) + } + }, + completion: { _ in } + ) } @IBAction dynamic func saturationSliderValueDidChange(_ sender: AnyObject?) { let saturation = self.saturationSlider?.value ?? 0 - CoreStore.beginAsynchronous { [weak self] (transaction) -> Void in - - if let palette = transaction.edit(self?.monitor?.object) { + CoreStore.perform( + asynchronous: { [weak self] (transaction) in - palette.saturation = saturation - transaction.commit() - } - } + if let palette = transaction.edit(self?.monitor?.object) { + + palette.saturation = saturation + } + }, + completion: { _ in } + ) } @IBAction dynamic func brightnessSliderValueDidChange(_ sender: AnyObject?) { let brightness = self.brightnessSlider?.value ?? 0 - CoreStore.beginAsynchronous { [weak self] (transaction) -> Void in - - if let palette = transaction.edit(self?.monitor?.object) { + CoreStore.perform( + asynchronous: { [weak self] (transaction) in - palette.brightness = brightness - transaction.commit() - } - } + if let palette = transaction.edit(self?.monitor?.object) { + + palette.brightness = brightness + } + }, + completion: { _ in } + ) } @IBAction dynamic func deleteBarButtonTapped(_ sender: AnyObject?) { - CoreStore.beginAsynchronous { [weak self] (transaction) -> Void in - - transaction.delete(self?.monitor?.object) - transaction.commit() - } + CoreStore.perform( + asynchronous: { [weak self] (transaction) in + + transaction.delete(self?.monitor?.object) + }, + completion: { _ in } + ) } func reloadPaletteInfo(_ palette: Palette, changedKeys: Set?) { diff --git a/CoreStoreDemo/CoreStoreDemo/Loggers Demo/CustomLoggerViewController.swift b/CoreStoreDemo/CoreStoreDemo/Loggers Demo/CustomLoggerViewController.swift index 9864f18..ff02f89 100644 --- a/CoreStoreDemo/CoreStoreDemo/Loggers Demo/CustomLoggerViewController.swift +++ b/CoreStoreDemo/CoreStoreDemo/Loggers Demo/CustomLoggerViewController.swift @@ -98,10 +98,9 @@ class CustomLoggerViewController: UIViewController, CoreStoreLogger { switch self.segmentedControl?.selectedSegmentIndex { case 0?: - self.dataStack.beginAsynchronous { (transaction) -> Void in - - _ = transaction.create(Into()) - } + let request = NSFetchRequest() + Where(true).applyToFetchRequest(request) + Where(false).applyToFetchRequest(request) case 1?: _ = try? dataStack.addStorageAndWait( @@ -112,10 +111,9 @@ class CustomLoggerViewController: UIViewController, CoreStoreLogger { ) case 2?: - self.dataStack.beginAsynchronous { (transaction) -> Void in + DispatchQueue.global(qos: .background).async { - transaction.commit() - transaction.commit() + _ = self.dataStack.fetchOne(From()) } default: diff --git a/CoreStoreDemo/CoreStoreDemo/MIgrations Demo/MigrationsDemoViewController.swift b/CoreStoreDemo/CoreStoreDemo/MIgrations Demo/MigrationsDemoViewController.swift index 4e823b7..34e149d 100644 --- a/CoreStoreDemo/CoreStoreDemo/MIgrations Demo/MigrationsDemoViewController.swift +++ b/CoreStoreDemo/CoreStoreDemo/MIgrations Demo/MigrationsDemoViewController.swift @@ -115,16 +115,17 @@ class MigrationsDemoViewController: UIViewController, ListObserver, UITableViewD self.setSelectedIndexPath(indexPath, scrollToSelection: false) self.setEnabled(false) - dataStack.beginAsynchronous { [weak self] (transaction) -> Void in - - let organism = transaction.edit(organism) as! OrganismProtocol - organism.mutate() - - transaction.commit { _ -> Void in + dataStack.perform( + asynchronous: { (transaction) in + + let organism = transaction.edit(organism) as! OrganismProtocol + organism.mutate() + }, + completion: { [weak self] _ in self?.setEnabled(true) } - } + ) } return cell } @@ -250,25 +251,26 @@ class MigrationsDemoViewController: UIViewController, ListObserver, UITableViewD for i: Int64 in 0 ..< 20 { - dataStack.beginAsynchronous { (transaction) -> Void in - - for j: Int64 in 0 ..< 500 { + dataStack.perform( + asynchronous: { (transaction) in - let organism = transaction.create(Into(model.entityType)) as! OrganismProtocol - organism.dna = (i * 500) + j + 1 - organism.mutate() - } - - transaction.commit() - } + for j: Int64 in 0 ..< 500 { + + let organism = transaction.create(Into(model.entityType)) as! OrganismProtocol + organism.dna = (i * 500) + j + 1 + organism.mutate() + } + }, + completion: { _ in } + ) } - dataStack.beginAsynchronous { [weak self] (transaction) -> Void in - - transaction.commit { _ in - + dataStack.perform( + asynchronous: { _ in }, + completion: { [weak self] _ in + self?.setEnabled(true) } - } + ) } } ) diff --git a/CoreStoreDemo/CoreStoreDemo/Stack Setup Demo/StackSetupDemoViewController.swift b/CoreStoreDemo/CoreStoreDemo/Stack Setup Demo/StackSetupDemoViewController.swift index 7dbbed2..b94c785 100644 --- a/CoreStoreDemo/CoreStoreDemo/Stack Setup Demo/StackSetupDemoViewController.swift +++ b/CoreStoreDemo/CoreStoreDemo/Stack Setup Demo/StackSetupDemoViewController.swift @@ -33,22 +33,22 @@ private struct Static { ) ) - _ = dataStack.beginSynchronous { (transaction) -> Void in - - transaction.deleteAll(From()) - - let account1 = transaction.create(Into(maleConfiguration)) - account1.accountType = "Facebook" - account1.name = "John Smith HCD" - account1.friends = 42 - - let account2 = transaction.create(Into(femaleConfiguration)) - account2.accountType = "Facebook" - account2.name = "Jane Doe HCD" - account2.friends = 314 - - _ = transaction.commitAndWait() - } + _ = try? dataStack.perform( + synchronous: { (transaction) in + + transaction.deleteAll(From()) + + let account1 = transaction.create(Into(maleConfiguration)) + account1.accountType = "Facebook" + account1.name = "John Smith HCD" + account1.friends = 42 + + let account2 = transaction.create(Into(femaleConfiguration)) + account2.accountType = "Facebook" + account2.name = "Jane Doe HCD" + account2.friends = 314 + } + ) return dataStack }() @@ -71,23 +71,22 @@ private struct Static { ) ) - _ = dataStack.beginSynchronous { (transaction) -> Void in - - transaction.deleteAll(From()) - - let account1 = transaction.create(Into(maleConfiguration)) - account1.accountType = "Twitter" - account1.name = "#johnsmith_hcd" - account1.friends = 7 - - let account2 = transaction.create(Into(femaleConfiguration)) - account2.accountType = "Twitter" - account2.name = "#janedoe_hcd" - account2.friends = 100 - - _ = transaction.commitAndWait() - } - + _ = try? dataStack.perform( + synchronous: { (transaction) in + + transaction.deleteAll(From()) + + let account1 = transaction.create(Into(maleConfiguration)) + account1.accountType = "Twitter" + account1.name = "#johnsmith_hcd" + account1.friends = 7 + + let account2 = transaction.create(Into(femaleConfiguration)) + account2.accountType = "Twitter" + account2.name = "#janedoe_hcd" + account2.friends = 100 + } + ) return dataStack }() } diff --git a/CoreStoreDemo/CoreStoreDemo/Transactions Demo/TransactionsDemoViewController.swift b/CoreStoreDemo/CoreStoreDemo/Transactions Demo/TransactionsDemoViewController.swift index 469dd10..254c96e 100644 --- a/CoreStoreDemo/CoreStoreDemo/Transactions Demo/TransactionsDemoViewController.swift +++ b/CoreStoreDemo/CoreStoreDemo/Transactions Demo/TransactionsDemoViewController.swift @@ -28,13 +28,13 @@ private struct Static { var place = CoreStore.fetchOne(From()) if place == nil { - _ = CoreStore.beginSynchronous { (transaction) -> Void in - - let place = transaction.create(Into()) - place.setInitialValues() - - _ = transaction.commitAndWait() - } + _ = try? CoreStore.perform( + synchronous: { (transaction) in + + let place = transaction.create(Into()) + place.setInitialValues() + } + ) place = CoreStore.fetchOne(From()) } @@ -169,23 +169,26 @@ class TransactionsDemoViewController: UIViewController, MKMapViewDelegate, Objec gesture.location(in: mapView), toCoordinateFrom: mapView ) - CoreStore.beginAsynchronous { (transaction) -> Void in - - let place = transaction.edit(Static.placeController.object) - place?.coordinate = coordinate - transaction.commit { (_) -> Void in } - } + CoreStore.perform( + asynchronous: { (transaction) in + + let place = transaction.edit(Static.placeController.object) + place?.coordinate = coordinate + }, + completion: { _ in } + ) } } @IBAction dynamic func refreshButtonTapped(_ sender: AnyObject?) { - _ = CoreStore.beginSynchronous { (transaction) -> Void in - - let place = transaction.edit(Static.placeController.object) - place?.setInitialValues() - _ = transaction.commitAndWait() - } + _ = try? CoreStore.perform( + synchronous: { (transaction) in + + let place = transaction.edit(Static.placeController.object) + place?.setInitialValues() + } + ) } func geocode(place: Place) { diff --git a/CoreStoreTests/BridgingTests.m b/CoreStoreTests/BridgingTests.m index cbd2f03..522cd45 100644 --- a/CoreStoreTests/BridgingTests.m +++ b/CoreStoreTests/BridgingTests.m @@ -213,20 +213,26 @@ XCTAssertNotNil(transaction); XCTAssert([transaction isKindOfClass:[CSUnsafeDataTransaction class]]); NSError *error; - XCTAssertTrue([transaction commitAndWaitWithError:&error]); + BOOL result = [transaction commitAndWaitWithError:&error]; + XCTAssertTrue(result); XCTAssertNil(error); } { XCTestExpectation *expectation = [self expectationWithDescription:@"sync"]; - [CSCoreStore beginSynchronous:^(CSSynchronousDataTransaction * _Nonnull transaction) { - - XCTAssertNotNil(transaction); - XCTAssert([transaction isKindOfClass:[CSSynchronousDataTransaction class]]); - NSError *error; - XCTAssertTrue([transaction commitAndWaitWithError:&error]); - XCTAssertNil(error); - [expectation fulfill]; - }]; + NSError *error; + BOOL result = [CSCoreStore + beginSynchronous:^(CSSynchronousDataTransaction * _Nonnull transaction) { + + XCTAssertNotNil(transaction); + XCTAssert([transaction isKindOfClass:[CSSynchronousDataTransaction class]]); + NSError *error; + XCTAssertTrue([transaction commitAndWaitWithError:&error]); + XCTAssertNil(error); + [expectation fulfill]; + } + error:&error]; + XCTAssertTrue(result); + XCTAssertNil(error); } { XCTestExpectation *expectation = [self expectationWithDescription:@"async"]; diff --git a/Sources/Fetching and Querying/BaseDataTransaction+Querying.swift b/Sources/Fetching and Querying/BaseDataTransaction+Querying.swift index 5f40738..a658e83 100644 --- a/Sources/Fetching and Querying/BaseDataTransaction+Querying.swift +++ b/Sources/Fetching and Querying/BaseDataTransaction+Querying.swift @@ -367,7 +367,7 @@ extension BaseDataTransaction: FetchableSource, QueryableSource { // MARK: Deprecated - @available(*, deprecated: 4.0.0, renamed: "unsafeContext()") + @available(*, deprecated, renamed: "unsafeContext()") public func internalContext() -> NSManagedObjectContext { return self.unsafeContext() diff --git a/Sources/Fetching and Querying/DataStack+Querying.swift b/Sources/Fetching and Querying/DataStack+Querying.swift index c7cba3a..3384446 100644 --- a/Sources/Fetching and Querying/DataStack+Querying.swift +++ b/Sources/Fetching and Querying/DataStack+Querying.swift @@ -330,7 +330,7 @@ extension DataStack: FetchableSource, QueryableSource { // MARK: Deprecated - @available(*, deprecated: 4.0.0, renamed: "unsafeContext()") + @available(*, deprecated, renamed: "unsafeContext()") public func internalContext() -> NSManagedObjectContext { return self.unsafeContext() diff --git a/Sources/Fetching and Querying/FetchableSource.swift b/Sources/Fetching and Querying/FetchableSource.swift index deb667c..13268ac 100644 --- a/Sources/Fetching and Querying/FetchableSource.swift +++ b/Sources/Fetching and Querying/FetchableSource.swift @@ -164,6 +164,6 @@ public protocol FetchableSource: class { // MARK: Deprecated - @available(*, deprecated: 4.0.0, renamed: "unsafeContext()") + @available(*, deprecated, renamed: "unsafeContext()") func internalContext() -> NSManagedObjectContext } diff --git a/Sources/Fetching and Querying/QueryableSource.swift b/Sources/Fetching and Querying/QueryableSource.swift index ba7f49b..b953d09 100644 --- a/Sources/Fetching and Querying/QueryableSource.swift +++ b/Sources/Fetching and Querying/QueryableSource.swift @@ -90,6 +90,6 @@ public protocol QueryableSource: class { // MARK: Deprecated - @available(*, deprecated: 4.0.0, renamed: "unsafeContext()") + @available(*, deprecated, renamed: "unsafeContext()") func internalContext() -> NSManagedObjectContext } diff --git a/Sources/Importing/ImportableObject.swift b/Sources/Importing/ImportableObject.swift index fdb9e0d..54f6c4c 100644 --- a/Sources/Importing/ImportableObject.swift +++ b/Sources/Importing/ImportableObject.swift @@ -95,13 +95,13 @@ public extension ImportableObject { // MARK: Obsolete - @available(*, obsoleted: 4.0.0, renamed: "shouldInsert(from:in:)") + @available(*, obsoleted: 3.0.0, renamed: "shouldInsert(from:in:)") static func shouldInsertFromImportSource(_ source: ImportSource, inTransaction transaction: BaseDataTransaction) -> Bool { return Self.shouldInsert(from: source, in: transaction) } - @available(*, obsoleted: 4.0.0, renamed: "didInsert(from:in:)") + @available(*, obsoleted: 3.0.0, renamed: "didInsert(from:in:)") func didInsertFromImportSource(_ source: ImportSource, inTransaction transaction: BaseDataTransaction) throws { try self.didInsert(from: source, in: transaction) diff --git a/Sources/Importing/ImportableUniqueObject.swift b/Sources/Importing/ImportableUniqueObject.swift index ac3776c..70a1c1e 100644 --- a/Sources/Importing/ImportableUniqueObject.swift +++ b/Sources/Importing/ImportableUniqueObject.swift @@ -157,31 +157,31 @@ public extension ImportableUniqueObject { // MARK: Obsolete - @available(*, obsoleted: 4.0.0, renamed: "shouldInsert(from:in:)") + @available(*, obsoleted: 3.0.0, renamed: "shouldInsert(from:in:)") static func shouldInsertFromImportSource(_ source: ImportSource, inTransaction transaction: BaseDataTransaction) -> Bool { return Self.shouldInsert(from: source, in: transaction) } - @available(*, obsoleted: 4.0.0, renamed: "shouldUpdate(from:in:)") + @available(*, obsoleted: 3.0.0, renamed: "shouldUpdate(from:in:)") static func shouldUpdateFromImportSource(_ source: ImportSource, inTransaction transaction: BaseDataTransaction) -> Bool { return Self.shouldUpdate(from: source, in: transaction) } - @available(*, obsoleted: 4.0.0, renamed: "uniqueID(from:in:)") + @available(*, obsoleted: 3.0.0, renamed: "uniqueID(from:in:)") static func uniqueIDFromImportSource(_ source: ImportSource, inTransaction transaction: BaseDataTransaction) throws -> UniqueIDType? { return try Self.uniqueID(from: source, in: transaction) } - @available(*, obsoleted: 4.0.0, renamed: "didInsert(from:in:)") + @available(*, obsoleted: 3.0.0, renamed: "didInsert(from:in:)") func didInsertFromImportSource(_ source: ImportSource, inTransaction transaction: BaseDataTransaction) throws { try self.didInsert(from: source, in: transaction) } - @available(*, obsoleted: 4.0.0, renamed: "update(from:in:)") + @available(*, obsoleted: 3.0.0, renamed: "update(from:in:)") func updateFromImportSource(_ source: ImportSource, inTransaction transaction: BaseDataTransaction) throws { try self.update(from: source, in: transaction) diff --git a/Sources/Internal/NSManagedObjectContext+Querying.swift b/Sources/Internal/NSManagedObjectContext+Querying.swift index 12934c1..7fe0c2c 100644 --- a/Sources/Internal/NSManagedObjectContext+Querying.swift +++ b/Sources/Internal/NSManagedObjectContext+Querying.swift @@ -298,7 +298,7 @@ extension NSManagedObjectContext: FetchableSource, QueryableSource { // MARK: Deprecated - @available(*, deprecated: 4.0.0, renamed: "unsafeContext()") + @available(*, deprecated, renamed: "unsafeContext()") public func internalContext() -> NSManagedObjectContext { return self.unsafeContext() diff --git a/Sources/Logging/CoreStore+CustomDebugStringConvertible.swift b/Sources/Logging/CoreStore+CustomDebugStringConvertible.swift index 1eba26e..b50f0e9 100644 --- a/Sources/Logging/CoreStore+CustomDebugStringConvertible.swift +++ b/Sources/Logging/CoreStore+CustomDebugStringConvertible.swift @@ -613,7 +613,7 @@ extension OrderBy: CustomDebugStringConvertible, CoreStoreDebugStringConvertible // MARK: - SaveResult -@available(*, deprecated: 4.0.0, message: "Use the new DataStack.perform(asynchronous:...) and DataStack.perform(synchronous:...) family of APIs") +@available(*, deprecated, message: "Use the new DataStack.perform(asynchronous:...) and DataStack.perform(synchronous:...) family of APIs") extension SaveResult: CustomDebugStringConvertible, CoreStoreDebugStringConvertible { // MARK: CustomDebugStringConvertible diff --git a/Sources/ObjectiveC/CSAsynchronousDataTransaction.swift b/Sources/ObjectiveC/CSAsynchronousDataTransaction.swift index aaaa017..dcba279 100644 --- a/Sources/ObjectiveC/CSAsynchronousDataTransaction.swift +++ b/Sources/ObjectiveC/CSAsynchronousDataTransaction.swift @@ -161,7 +161,7 @@ public final class CSAsynchronousDataTransaction: CSBaseDataTransaction { - parameter completion: the block executed after the save completes. Success or failure is reported by the `CSSaveResult` argument of the block. */ - @available(*, deprecated: 4.0.0, message: "Use the new -[CSAsynchronousDataTransaction commitWithSuccess:failure:] method.") + @available(*, deprecated, message: "Use the new -[CSAsynchronousDataTransaction commitWithSuccess:failure:] method.") @objc public func commitWithCompletion(_ completion: ((_ result: CSSaveResult) -> Void)?) { @@ -185,7 +185,7 @@ public final class CSAsynchronousDataTransaction: CSBaseDataTransaction { - 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 `CSSaveResult` value indicating success or failure, or `nil` if the transaction was not comitted synchronously */ - @available(*, deprecated: 4.0.0, message: "Secondary tasks spawned from CSAsynchronousDataTransactions and CSSynchronousDataTransactions are no longer supported. ") + @available(*, deprecated, message: "Secondary tasks spawned from CSAsynchronousDataTransactions and CSSynchronousDataTransactions are no longer supported. ") @objc @discardableResult public func beginSynchronous(_ closure: @escaping (_ transaction: CSSynchronousDataTransaction) -> Void) -> CSSaveResult? { diff --git a/Sources/ObjectiveC/CSCoreStore+Transaction.swift b/Sources/ObjectiveC/CSCoreStore+Transaction.swift index ce8f0fc..2c2f8a0 100644 --- a/Sources/ObjectiveC/CSCoreStore+Transaction.swift +++ b/Sources/ObjectiveC/CSCoreStore+Transaction.swift @@ -101,7 +101,7 @@ public extension CSCoreStore { - 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 `CSSaveResult` value indicating success or failure, or `nil` if the transaction was not comitted synchronously */ - @available(*, deprecated: 4.0.0, message: "Use the new +[CSCoreStore beginSynchronous:error:] API that reports failure using an error instance.") + @available(*, deprecated, message: "Use the new +[CSCoreStore beginSynchronous:error:] API that reports failure using an error instance.") @objc @discardableResult public static func beginSynchronous(_ closure: @escaping (_ transaction: CSSynchronousDataTransaction) -> Void) -> CSSaveResult? { diff --git a/Sources/ObjectiveC/CSDataStack+Transaction.swift b/Sources/ObjectiveC/CSDataStack+Transaction.swift index 63d4ef8..b6f161e 100644 --- a/Sources/ObjectiveC/CSDataStack+Transaction.swift +++ b/Sources/ObjectiveC/CSDataStack+Transaction.swift @@ -141,7 +141,7 @@ public extension CSDataStack { - 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 `CSSaveResult` value indicating success or failure, or `nil` if the transaction was not comitted synchronously */ - @available(*, deprecated: 4.0.0, message: "Use the new -[CSDataStack beginSynchronous:error:] API that reports failure using an error instance.") + @available(*, deprecated, message: "Use the new -[CSDataStack beginSynchronous:error:] API that reports failure using an error instance.") @objc @discardableResult public func beginSynchronous(_ closure: @escaping (_ transaction: CSSynchronousDataTransaction) -> Void) -> CSSaveResult? { diff --git a/Sources/ObjectiveC/CSSaveResult.swift b/Sources/ObjectiveC/CSSaveResult.swift index 5a955fe..7f0fcbd 100644 --- a/Sources/ObjectiveC/CSSaveResult.swift +++ b/Sources/ObjectiveC/CSSaveResult.swift @@ -34,7 +34,7 @@ import CoreData - SeeAlso: `SaveResult` */ -@available(*, deprecated: 4.0.0, message: "Use APIs that report failures with `CSError`s instead.") +@available(*, deprecated, message: "Use APIs that report failures with `CSError`s instead.") @objc public final class CSSaveResult: NSObject, CoreStoreObjectiveCType { @@ -174,7 +174,7 @@ public final class CSSaveResult: NSObject, CoreStoreObjectiveCType { // MARK: - SaveResult -@available(*, deprecated: 4.0.0, message: "Use the new DataStack.perform(asynchronous:...) and DataStack.perform(synchronous:...) family of APIs") +@available(*, deprecated, message: "Use the new DataStack.perform(asynchronous:...) and DataStack.perform(synchronous:...) family of APIs") extension SaveResult: CoreStoreSwiftType { // MARK: CoreStoreSwiftType diff --git a/Sources/ObjectiveC/CSSynchronousDataTransaction.swift b/Sources/ObjectiveC/CSSynchronousDataTransaction.swift index 792ac91..747008b 100644 --- a/Sources/ObjectiveC/CSSynchronousDataTransaction.swift +++ b/Sources/ObjectiveC/CSSynchronousDataTransaction.swift @@ -152,7 +152,7 @@ public final class CSSynchronousDataTransaction: CSBaseDataTransaction { - returns: a `CSSaveResult` containing the success or failure information */ - @available(*, deprecated: 4.0.0, message: "Use the new -[CSSynchronousDataTransaction commitAndWaitWithError:] method") + @available(*, deprecated, message: "Use the new -[CSSynchronousDataTransaction commitAndWaitWithError:] method") @objc public func commitAndWait() -> CSSaveResult { @@ -168,7 +168,7 @@ public final class CSSynchronousDataTransaction: CSBaseDataTransaction { - 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 `CSSaveResult` value indicating success or failure, or `nil` if the transaction was not comitted synchronously */ - @available(*, deprecated: 4.0.0, message: "Secondary tasks spawned from CSAsynchronousDataTransactions and CSSynchronousDataTransactions are no longer supported. ") + @available(*, deprecated, message: "Secondary tasks spawned from CSAsynchronousDataTransactions and CSSynchronousDataTransactions are no longer supported. ") @objc @discardableResult public func beginSynchronous(_ closure: @escaping (_ transaction: CSSynchronousDataTransaction) -> Void) -> CSSaveResult? { diff --git a/Sources/ObjectiveC/CSUnsafeDataTransaction.swift b/Sources/ObjectiveC/CSUnsafeDataTransaction.swift index 6bdcf97..beba7ce 100644 --- a/Sources/ObjectiveC/CSUnsafeDataTransaction.swift +++ b/Sources/ObjectiveC/CSUnsafeDataTransaction.swift @@ -203,7 +203,7 @@ public final class CSUnsafeDataTransaction: CSBaseDataTransaction { // MARK: Deprecated - @available(*, deprecated: 4.0.0, renamed: "unsafeContext()") + @available(*, deprecated, renamed: "unsafeContext()") @objc public var internalContext: NSManagedObjectContext { @@ -215,7 +215,7 @@ public final class CSUnsafeDataTransaction: CSBaseDataTransaction { - parameter completion: the block executed after the save completes. Success or failure is reported by the `CSSaveResult` argument of the block. */ - @available(*, deprecated: 4.0.0, message: "Use the new -[CSUnsafeDataTransaction commitWithSuccess:failure:] method") + @available(*, deprecated, message: "Use the new -[CSUnsafeDataTransaction commitWithSuccess:failure:] method") @objc public func commit(_ completion: ((_ result: CSSaveResult) -> Void)?) { @@ -238,7 +238,7 @@ public final class CSUnsafeDataTransaction: CSBaseDataTransaction { - returns: a `CSSaveResult` containing the success or failure information */ - @available(*, deprecated: 4.0.0, message: "Use the new -[CSUnsafeDataTransaction commitAndWaitWithError:] method") + @available(*, deprecated, message: "Use the new -[CSUnsafeDataTransaction commitAndWaitWithError:] method") @objc public func commitAndWait() -> CSSaveResult { diff --git a/Sources/Setup/CoreStore+Setup.swift b/Sources/Setup/CoreStore+Setup.swift index cbf1d94..d1c57ef 100644 --- a/Sources/Setup/CoreStore+Setup.swift +++ b/Sources/Setup/CoreStore+Setup.swift @@ -157,7 +157,7 @@ public extension CoreStore { // MARK: Obsolete - @available(*, obsoleted: 4.0.0, renamed: "entityDescription(for:)") + @available(*, obsoleted: 3.0.0, renamed: "entityDescription(for:)") public static func entityDescriptionForType(_ type: NSManagedObject.Type) -> NSEntityDescription? { return self.entityDescription(for: type) diff --git a/Sources/Setup/DataStack.swift b/Sources/Setup/DataStack.swift index 466572e..2621f7c 100644 --- a/Sources/Setup/DataStack.swift +++ b/Sources/Setup/DataStack.swift @@ -530,13 +530,13 @@ public final class DataStack: Equatable { // MARK: Obsolete - @available(*, obsoleted: 4.0.0, renamed: "entityDescription(for:)") + @available(*, obsoleted: 3.0.0, renamed: "entityDescription(for:)") public func entityDescriptionForType(_ type: NSManagedObject.Type) -> NSEntityDescription? { return self.entityDescription(for: type) } - @available(*, obsoleted: 4.0.0, renamed: "objectID(forURIRepresentation:)") + @available(*, obsoleted: 3.0.0, renamed: "objectID(forURIRepresentation:)") public func objectIDForURIRepresentation(_ url: URL) -> NSManagedObjectID? { return self.objectID(forURIRepresentation: url) diff --git a/Sources/Transactions/AsynchronousDataTransaction.swift b/Sources/Transactions/AsynchronousDataTransaction.swift index 396a3e0..b3eaac3 100644 --- a/Sources/Transactions/AsynchronousDataTransaction.swift +++ b/Sources/Transactions/AsynchronousDataTransaction.swift @@ -208,7 +208,7 @@ public final class AsynchronousDataTransaction: BaseDataTransaction { - parameter completion: the block executed after the save completes. Success or failure is reported by the `SaveResult` argument of the block. */ - @available(*, deprecated: 4.0.0, message: "Use the new auto-commiting methods `DataStack.perform(asynchronous:completion:)` or `DataStack.perform(asynchronous:success:failure:)`. Please read the documentation on the behavior of the new methods.") + @available(*, deprecated, message: "Use the new auto-commiting methods `DataStack.perform(asynchronous:completion:)` or `DataStack.perform(asynchronous:success:failure:)`. Please read the documentation on the behavior of the new methods.") public func commit(_ completion: @escaping (_ result: SaveResult) -> Void = { _ in }) { CoreStore.assert( @@ -235,7 +235,7 @@ public final class AsynchronousDataTransaction: 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 */ - @available(*, deprecated: 4.0.0, message: "Secondary tasks spawned from AsynchronousDataTransactions and SynchronousDataTransactions are no longer supported. ") + @available(*, deprecated, message: "Secondary tasks spawned from AsynchronousDataTransactions and SynchronousDataTransactions are no longer supported. ") @discardableResult public func beginSynchronous(_ closure: @escaping (_ transaction: SynchronousDataTransaction) -> Void) -> SaveResult? { diff --git a/Sources/Transactions/CoreStore+Transaction.swift b/Sources/Transactions/CoreStore+Transaction.swift index 54c79f0..eb7e121 100644 --- a/Sources/Transactions/CoreStore+Transaction.swift +++ b/Sources/Transactions/CoreStore+Transaction.swift @@ -93,7 +93,7 @@ public extension CoreStore { - 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`. */ - @available(*, deprecated: 4.0.0, message: "Use the new auto-commiting methods `perform(asynchronous:completion:)` or `perform(asynchronous:success:failure:)`. Please read the documentation on the behavior of the new methods.") + @available(*, deprecated, message: "Use the new auto-commiting methods `perform(asynchronous:completion:)` or `perform(asynchronous:success:failure:)`. Please read the documentation on the behavior of the new methods.") public static func beginAsynchronous(_ closure: @escaping (_ transaction: AsynchronousDataTransaction) -> Void) { self.defaultStack.beginAsynchronous(closure) @@ -105,7 +105,7 @@ public extension CoreStore { - 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 */ - @available(*, deprecated: 4.0.0, message: "Use the new auto-commiting method `perform(synchronous:)`. Please read the documentation on the behavior of the new methods.") + @available(*, deprecated, message: "Use the new auto-commiting method `perform(synchronous:)`. Please read the documentation on the behavior of the new methods.") @discardableResult public static func beginSynchronous(_ closure: @escaping (_ transaction: SynchronousDataTransaction) -> Void) -> SaveResult? { diff --git a/Sources/Transactions/DataStack+Transaction.swift b/Sources/Transactions/DataStack+Transaction.swift index 00d7518..5a91370 100644 --- a/Sources/Transactions/DataStack+Transaction.swift +++ b/Sources/Transactions/DataStack+Transaction.swift @@ -165,7 +165,7 @@ public extension DataStack { - 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`. */ - @available(*, deprecated: 4.0.0, message: "Use the new auto-commiting methods `perform(asynchronous:completion:)` or `perform(asynchronous:success:failure:)`. Please read the documentation on the behavior of the new methods.") + @available(*, deprecated, message: "Use the new auto-commiting methods `perform(asynchronous:completion:)` or `perform(asynchronous:success:failure:)`. Please read the documentation on the behavior of the new methods.") public func beginAsynchronous(_ closure: @escaping (_ transaction: AsynchronousDataTransaction) -> Void) { let transaction = AsynchronousDataTransaction( @@ -192,7 +192,7 @@ public extension DataStack { - 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 */ - @available(*, deprecated: 4.0.0, message: "Use the new auto-commiting method `perform(synchronous:)`. Please read the documentation on the behavior of the new methods.") + @available(*, deprecated, message: "Use the new auto-commiting method `perform(synchronous:)`. Please read the documentation on the behavior of the new methods.") @discardableResult public func beginSynchronous(_ closure: @escaping (_ transaction: SynchronousDataTransaction) -> Void) -> SaveResult? { diff --git a/Sources/Transactions/SaveResult.swift b/Sources/Transactions/SaveResult.swift index 8735818..79d3e27 100644 --- a/Sources/Transactions/SaveResult.swift +++ b/Sources/Transactions/SaveResult.swift @@ -57,7 +57,7 @@ import Foundation } ``` */ -@available(*, deprecated: 4.0.0, message: "Use the new DataStack.perform(asynchronous:...) and DataStack.perform(synchronous:...) family of APIs") +@available(*, deprecated, message: "Use the new DataStack.perform(asynchronous:...) and DataStack.perform(synchronous:...) family of APIs") public enum SaveResult: Hashable { /** diff --git a/Sources/Transactions/SynchronousDataTransaction.swift b/Sources/Transactions/SynchronousDataTransaction.swift index 74c1c4d..d390c69 100644 --- a/Sources/Transactions/SynchronousDataTransaction.swift +++ b/Sources/Transactions/SynchronousDataTransaction.swift @@ -170,7 +170,7 @@ public final class SynchronousDataTransaction: BaseDataTransaction { - returns: a `SaveResult` containing the success or failure information */ - @available(*, deprecated: 4.0.0, message: "Use the new auto-commit method DataStack.perform(synchronous:waitForAllObservers:)") + @available(*, deprecated, message: "Use the new auto-commit method DataStack.perform(synchronous:waitForAllObservers:)") public func commitAndWait() -> SaveResult { CoreStore.assert( @@ -194,7 +194,7 @@ public final class SynchronousDataTransaction: BaseDataTransaction { - returns: a `SaveResult` containing the success or failure information */ - @available(*, deprecated: 4.0.0, message: "Use the new auto-commit method DataStack.perform(synchronous:waitForAllObservers:)") + @available(*, deprecated, message: "Use the new auto-commit method DataStack.perform(synchronous:waitForAllObservers:)") public func commit() -> SaveResult { CoreStore.assert( @@ -218,7 +218,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 */ - @available(*, deprecated: 4.0.0, message: "Secondary tasks spawned from AsynchronousDataTransactions and SynchronousDataTransactions are no longer supported. ") + @available(*, deprecated, message: "Secondary tasks spawned from AsynchronousDataTransactions and SynchronousDataTransactions are no longer supported. ") @discardableResult public func beginSynchronous(_ closure: @escaping (_ transaction: SynchronousDataTransaction) -> Void) -> SaveResult? {