From 22943d2c76881f21edf2eda8317230c186f7a219 Mon Sep 17 00:00:00 2001 From: John Rommel Estropia Date: Sat, 29 Aug 2015 22:29:03 +0900 Subject: [PATCH] added warn_unused_result annotations where they seem reasonable --- .../NSManagedObject+Convenience.swift | 1 + .../BaseDataTransaction+Querying.swift | 18 ++++++++++++++++++ .../CoreStore+Querying.swift | 18 ++++++++++++++++++ .../DataStack+Querying.swift | 18 ++++++++++++++++++ CoreStore/Migrating/CoreStore+Migration.swift | 2 ++ CoreStore/Migrating/DataStack+Migration.swift | 2 ++ CoreStore/Observing/CoreStore+Observing.swift | 5 +++++ CoreStore/Observing/DataStack+Observing.swift | 5 +++++ CoreStore/Observing/ListMonitor.swift | 13 +++++++++++++ .../AsynchronousDataTransaction.swift | 2 ++ .../BaseDataTransaction.swift | 2 ++ .../CoreStore+Transaction.swift | 1 + .../DataStack+Transaction.swift | 1 + .../DetachedDataTransaction.swift | 1 + .../SynchronousDataTransaction.swift | 2 ++ 15 files changed, 91 insertions(+) diff --git a/CoreStore/Convenience Helpers/NSManagedObject+Convenience.swift b/CoreStore/Convenience Helpers/NSManagedObject+Convenience.swift index fe33339..2eb1a59 100644 --- a/CoreStore/Convenience Helpers/NSManagedObject+Convenience.swift +++ b/CoreStore/Convenience Helpers/NSManagedObject+Convenience.swift @@ -37,6 +37,7 @@ public extension NSManagedObject { - parameter KVCKey: the KVC key - returns: the primitive value for the KVC key */ + @warn_unused_result public func accessValueForKVCKey(KVCKey: KeyPath) -> AnyObject? { self.willAccessValueForKey(KVCKey) diff --git a/CoreStore/Fetching and Querying/BaseDataTransaction+Querying.swift b/CoreStore/Fetching and Querying/BaseDataTransaction+Querying.swift index f199328..ef01611 100644 --- a/CoreStore/Fetching and Querying/BaseDataTransaction+Querying.swift +++ b/CoreStore/Fetching and Querying/BaseDataTransaction+Querying.swift @@ -39,6 +39,7 @@ public extension BaseDataTransaction { - parameter object: a reference to the object created/fetched outside the transaction - returns: the `NSManagedObject` instance if the object exists in the transaction, or `nil` if not found. */ + @warn_unused_result public func fetchExisting(object: T) -> T? { do { @@ -57,6 +58,7 @@ public extension BaseDataTransaction { - parameter objectID: the `NSManagedObjectID` for the object - returns: the `NSManagedObject` instance if the object exists in the transaction, or `nil` if not found. */ + @warn_unused_result public func fetchExisting(objectID: NSManagedObjectID) -> T? { do { @@ -75,6 +77,7 @@ public extension BaseDataTransaction { - parameter objects: an array of `NSManagedObject`s created/fetched outside the transaction - returns: the `NSManagedObject` array for objects that exists in the transaction */ + @warn_unused_result public func fetchExisting(objects: [T]) -> [T] { var existingObjects = [T]() @@ -94,6 +97,7 @@ public extension BaseDataTransaction { - parameter objectIDs: the `NSManagedObjectID` array for the objects - returns: the `NSManagedObject` array for objects that exists in the transaction */ + @warn_unused_result public func fetchExisting(objectIDs: [NSManagedObjectID]) -> [T] { var existingObjects = [T]() @@ -114,6 +118,7 @@ public extension BaseDataTransaction { - parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - returns: the first `NSManagedObject` instance that satisfies the specified `FetchClause`s */ + @warn_unused_result public func fetchOne(from: From, _ fetchClauses: FetchClause...) -> T? { CoreStore.assert( @@ -131,6 +136,7 @@ public extension BaseDataTransaction { - parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - returns: the first `NSManagedObject` instance that satisfies the specified `FetchClause`s */ + @warn_unused_result public func fetchOne(from: From, _ fetchClauses: [FetchClause]) -> T? { CoreStore.assert( @@ -148,6 +154,7 @@ public extension BaseDataTransaction { - parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - returns: all `NSManagedObject` instances that satisfy the specified `FetchClause`s */ + @warn_unused_result public func fetchAll(from: From, _ fetchClauses: FetchClause...) -> [T]? { CoreStore.assert( @@ -165,6 +172,7 @@ public extension BaseDataTransaction { - parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - returns: all `NSManagedObject` instances that satisfy the specified `FetchClause`s */ + @warn_unused_result public func fetchAll(from: From, _ fetchClauses: [FetchClause]) -> [T]? { CoreStore.assert( @@ -182,6 +190,7 @@ public extension BaseDataTransaction { - parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - returns: the number `NSManagedObject`s that satisfy the specified `FetchClause`s */ + @warn_unused_result public func fetchCount(from: From, _ fetchClauses: FetchClause...) -> Int? { CoreStore.assert( @@ -199,6 +208,7 @@ public extension BaseDataTransaction { - parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - returns: the number `NSManagedObject`s that satisfy the specified `FetchClause`s */ + @warn_unused_result public func fetchCount(from: From, _ fetchClauses: [FetchClause]) -> Int? { CoreStore.assert( @@ -216,6 +226,7 @@ public extension BaseDataTransaction { - parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - returns: the `NSManagedObjectID` for the first `NSManagedObject` that satisfies the specified `FetchClause`s */ + @warn_unused_result public func fetchObjectID(from: From, _ fetchClauses: FetchClause...) -> NSManagedObjectID? { CoreStore.assert( @@ -233,6 +244,7 @@ public extension BaseDataTransaction { - parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - returns: the `NSManagedObjectID` for the first `NSManagedObject` that satisfies the specified `FetchClause`s */ + @warn_unused_result public func fetchObjectID(from: From, _ fetchClauses: [FetchClause]) -> NSManagedObjectID? { CoreStore.assert( @@ -250,6 +262,7 @@ public extension BaseDataTransaction { - parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - returns: the `NSManagedObjectID` for all `NSManagedObject`s that satisfy the specified `FetchClause`s */ + @warn_unused_result public func fetchObjectIDs(from: From, _ fetchClauses: FetchClause...) -> [NSManagedObjectID]? { CoreStore.assert( @@ -267,6 +280,7 @@ public extension BaseDataTransaction { - parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - returns: the `NSManagedObjectID` for all `NSManagedObject`s that satisfy the specified `FetchClause`s */ + @warn_unused_result public func fetchObjectIDs(from: From, _ fetchClauses: [FetchClause]) -> [NSManagedObjectID]? { CoreStore.assert( @@ -321,6 +335,7 @@ public extension BaseDataTransaction { - parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses. - returns: the result of the the query. The type of the return value is specified by the generic type of the `Select` parameter. */ + @warn_unused_result public func queryValue(from: From, _ selectClause: Select, _ queryClauses: QueryClause...) -> U? { CoreStore.assert( @@ -341,6 +356,7 @@ public extension BaseDataTransaction { - parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses. - returns: the result of the the query. The type of the return value is specified by the generic type of the `Select` parameter. */ + @warn_unused_result public func queryValue(from: From, _ selectClause: Select, _ queryClauses: [QueryClause]) -> U? { CoreStore.assert( @@ -361,6 +377,7 @@ public extension BaseDataTransaction { - parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses. - returns: the result of the the query. The type of the return value is specified by the generic type of the `Select` parameter. */ + @warn_unused_result public func queryAttributes(from: From, _ selectClause: Select, _ queryClauses: QueryClause...) -> [[NSString: AnyObject]]? { CoreStore.assert( @@ -381,6 +398,7 @@ public extension BaseDataTransaction { - parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses. - returns: the result of the the query. The type of the return value is specified by the generic type of the `Select` parameter. */ + @warn_unused_result public func queryAttributes(from: From, _ selectClause: Select, _ queryClauses: [QueryClause]) -> [[NSString: AnyObject]]? { CoreStore.assert( diff --git a/CoreStore/Fetching and Querying/CoreStore+Querying.swift b/CoreStore/Fetching and Querying/CoreStore+Querying.swift index c44db1b..3fb065c 100644 --- a/CoreStore/Fetching and Querying/CoreStore+Querying.swift +++ b/CoreStore/Fetching and Querying/CoreStore+Querying.swift @@ -37,6 +37,7 @@ public extension CoreStore { - parameter object: a reference to the object created/fetched outside the `DataStack` - returns: the `NSManagedObject` instance if the object exists in the `DataStack`, or `nil` if not found. */ + @warn_unused_result public static func fetchExisting(object: T) -> T? { return self.defaultStack.fetchExisting(object) @@ -48,6 +49,7 @@ public extension CoreStore { - parameter objectID: the `NSManagedObjectID` for the object - returns: the `NSManagedObject` instance if the object exists in the `DataStack`, or `nil` if not found. */ + @warn_unused_result public static func fetchExisting(objectID: NSManagedObjectID) -> T? { return self.defaultStack.fetchExisting(objectID) @@ -59,6 +61,7 @@ public extension CoreStore { - parameter objects: an array of `NSManagedObject`s created/fetched outside the `DataStack` - returns: the `NSManagedObject` array for objects that exists in the `DataStack` */ + @warn_unused_result public static func fetchExisting(objects: [T]) -> [T] { return self.defaultStack.fetchExisting(objects) @@ -70,6 +73,7 @@ public extension CoreStore { - parameter objectIDs: the `NSManagedObjectID` array for the objects - returns: the `NSManagedObject` array for objects that exists in the `DataStack` */ + @warn_unused_result public static func fetchExisting(objectIDs: [NSManagedObjectID]) -> [T] { return self.defaultStack.fetchExisting(objectIDs) @@ -82,6 +86,7 @@ public extension CoreStore { - parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - returns: the first `NSManagedObject` instance that satisfies the specified `FetchClause`s */ + @warn_unused_result public static func fetchOne(from: From, _ fetchClauses: FetchClause...) -> T? { return self.defaultStack.fetchOne(from, fetchClauses) @@ -94,6 +99,7 @@ public extension CoreStore { - parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - returns: the first `NSManagedObject` instance that satisfies the specified `FetchClause`s */ + @warn_unused_result public static func fetchOne(from: From, _ fetchClauses: [FetchClause]) -> T? { return self.defaultStack.fetchOne(from, fetchClauses) @@ -106,6 +112,7 @@ public extension CoreStore { - parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - returns: all `NSManagedObject` instances that satisfy the specified `FetchClause`s */ + @warn_unused_result public static func fetchAll(from: From, _ fetchClauses: FetchClause...) -> [T]? { return self.defaultStack.fetchAll(from, fetchClauses) @@ -118,6 +125,7 @@ public extension CoreStore { - parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - returns: all `NSManagedObject` instances that satisfy the specified `FetchClause`s */ + @warn_unused_result public static func fetchAll(from: From, _ fetchClauses: [FetchClause]) -> [T]? { return self.defaultStack.fetchAll(from, fetchClauses) @@ -130,6 +138,7 @@ public extension CoreStore { - parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - returns: the number `NSManagedObject`s that satisfy the specified `FetchClause`s */ + @warn_unused_result public static func fetchCount(from: From, _ fetchClauses: FetchClause...) -> Int? { return self.defaultStack.fetchCount(from, fetchClauses) @@ -142,6 +151,7 @@ public extension CoreStore { - parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - returns: the number `NSManagedObject`s that satisfy the specified `FetchClause`s */ + @warn_unused_result public static func fetchCount(from: From, _ fetchClauses: [FetchClause]) -> Int? { return self.defaultStack.fetchCount(from, fetchClauses) @@ -154,6 +164,7 @@ public extension CoreStore { - parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - returns: the `NSManagedObjectID` for the first `NSManagedObject` that satisfies the specified `FetchClause`s */ + @warn_unused_result public static func fetchObjectID(from: From, _ fetchClauses: FetchClause...) -> NSManagedObjectID? { return self.defaultStack.fetchObjectID(from, fetchClauses) @@ -166,6 +177,7 @@ public extension CoreStore { - parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - returns: the `NSManagedObjectID` for the first `NSManagedObject` that satisfies the specified `FetchClause`s */ + @warn_unused_result public static func fetchObjectID(from: From, _ fetchClauses: [FetchClause]) -> NSManagedObjectID? { return self.defaultStack.fetchObjectID(from, fetchClauses) @@ -178,6 +190,7 @@ public extension CoreStore { - parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - returns: the `NSManagedObjectID` for all `NSManagedObject`s that satisfy the specified `FetchClause`s */ + @warn_unused_result public static func fetchObjectIDs(from: From, _ fetchClauses: FetchClause...) -> [NSManagedObjectID]? { return self.defaultStack.fetchObjectIDs(from, fetchClauses) @@ -190,6 +203,7 @@ public extension CoreStore { - parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - returns: the `NSManagedObjectID` for all `NSManagedObject`s that satisfy the specified `FetchClause`s */ + @warn_unused_result public static func fetchObjectIDs(from: From, _ fetchClauses: [FetchClause]) -> [NSManagedObjectID]? { return self.defaultStack.fetchObjectIDs(from, fetchClauses) @@ -205,6 +219,7 @@ public extension CoreStore { - parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses. - returns: the result of the the query. The type of the return value is specified by the generic type of the `Select` parameter. */ + @warn_unused_result public static func queryValue(from: From, _ selectClause: Select, _ queryClauses: QueryClause...) -> U? { return self.defaultStack.queryValue(from, selectClause, queryClauses) @@ -220,6 +235,7 @@ public extension CoreStore { - parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses. - returns: the result of the the query. The type of the return value is specified by the generic type of the `Select` parameter. */ + @warn_unused_result public static func queryValue(from: From, _ selectClause: Select, _ queryClauses: [QueryClause]) -> U? { return self.defaultStack.queryValue(from, selectClause, queryClauses) @@ -235,6 +251,7 @@ public extension CoreStore { - parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses. - returns: the result of the the query. The type of the return value is specified by the generic type of the `Select` parameter. */ + @warn_unused_result public static func queryAttributes(from: From, _ selectClause: Select, _ queryClauses: QueryClause...) -> [[NSString: AnyObject]]? { return self.defaultStack.queryAttributes(from, selectClause, queryClauses) @@ -250,6 +267,7 @@ public extension CoreStore { - parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses. - returns: the result of the the query. The type of the return value is specified by the generic type of the `Select` parameter. */ + @warn_unused_result public static func queryAttributes(from: From, _ selectClause: Select, _ queryClauses: [QueryClause]) -> [[NSString: AnyObject]]? { return self.defaultStack.queryAttributes(from, selectClause, queryClauses) diff --git a/CoreStore/Fetching and Querying/DataStack+Querying.swift b/CoreStore/Fetching and Querying/DataStack+Querying.swift index 601f4b1..7c77842 100644 --- a/CoreStore/Fetching and Querying/DataStack+Querying.swift +++ b/CoreStore/Fetching and Querying/DataStack+Querying.swift @@ -40,6 +40,7 @@ public extension DataStack { - parameter object: a reference to the object created/fetched outside the `DataStack` - returns: the `NSManagedObject` instance if the object exists in the `DataStack`, or `nil` if not found. */ + @warn_unused_result public func fetchExisting(object: T) -> T? { do { @@ -58,6 +59,7 @@ public extension DataStack { - parameter objectID: the `NSManagedObjectID` for the object - returns: the `NSManagedObject` instance if the object exists in the `DataStack`, or `nil` if not found. */ + @warn_unused_result public func fetchExisting(objectID: NSManagedObjectID) -> T? { do { @@ -76,6 +78,7 @@ public extension DataStack { - parameter objects: an array of `NSManagedObject`s created/fetched outside the `DataStack` - returns: the `NSManagedObject` array for objects that exists in the `DataStack` */ + @warn_unused_result public func fetchExisting(objects: [T]) -> [T] { var existingObjects = [T]() @@ -95,6 +98,7 @@ public extension DataStack { - parameter objectIDs: the `NSManagedObjectID` array for the objects - returns: the `NSManagedObject` array for objects that exists in the `DataStack` */ + @warn_unused_result public func fetchExisting(objectIDs: [NSManagedObjectID]) -> [T] { var existingObjects = [T]() @@ -115,6 +119,7 @@ public extension DataStack { - parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - returns: the first `NSManagedObject` instance that satisfies the specified `FetchClause`s */ + @warn_unused_result public func fetchOne(from: From, _ fetchClauses: FetchClause...) -> T? { CoreStore.assert( @@ -132,6 +137,7 @@ public extension DataStack { - parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - returns: the first `NSManagedObject` instance that satisfies the specified `FetchClause`s */ + @warn_unused_result public func fetchOne(from: From, _ fetchClauses: [FetchClause]) -> T? { CoreStore.assert( @@ -149,6 +155,7 @@ public extension DataStack { - parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - returns: all `NSManagedObject` instances that satisfy the specified `FetchClause`s */ + @warn_unused_result public func fetchAll(from: From, _ fetchClauses: FetchClause...) -> [T]? { CoreStore.assert( @@ -166,6 +173,7 @@ public extension DataStack { - parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - returns: all `NSManagedObject` instances that satisfy the specified `FetchClause`s */ + @warn_unused_result public func fetchAll(from: From, _ fetchClauses: [FetchClause]) -> [T]? { CoreStore.assert( @@ -183,6 +191,7 @@ public extension DataStack { - parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - returns: the number `NSManagedObject`s that satisfy the specified `FetchClause`s */ + @warn_unused_result public func fetchCount(from: From, _ fetchClauses: FetchClause...) -> Int? { CoreStore.assert( @@ -200,6 +209,7 @@ public extension DataStack { - parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - returns: the number `NSManagedObject`s that satisfy the specified `FetchClause`s */ + @warn_unused_result public func fetchCount(from: From, _ fetchClauses: [FetchClause]) -> Int? { CoreStore.assert( @@ -217,6 +227,7 @@ public extension DataStack { - parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - returns: the `NSManagedObjectID` for the first `NSManagedObject` that satisfies the specified `FetchClause`s */ + @warn_unused_result public func fetchObjectID(from: From, _ fetchClauses: FetchClause...) -> NSManagedObjectID? { CoreStore.assert( @@ -234,6 +245,7 @@ public extension DataStack { - parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - returns: the `NSManagedObjectID` for the first `NSManagedObject` that satisfies the specified `FetchClause`s */ + @warn_unused_result public func fetchObjectID(from: From, _ fetchClauses: [FetchClause]) -> NSManagedObjectID? { CoreStore.assert( @@ -251,6 +263,7 @@ public extension DataStack { - parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - returns: the `NSManagedObjectID` for all `NSManagedObject`s that satisfy the specified `FetchClause`s */ + @warn_unused_result public func fetchObjectIDs(from: From, _ fetchClauses: FetchClause...) -> [NSManagedObjectID]? { CoreStore.assert( @@ -268,6 +281,7 @@ public extension DataStack { - parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - returns: the `NSManagedObjectID` for all `NSManagedObject`s that satisfy the specified `FetchClause`s */ + @warn_unused_result public func fetchObjectIDs(from: From, _ fetchClauses: [FetchClause]) -> [NSManagedObjectID]? { CoreStore.assert( @@ -288,6 +302,7 @@ public extension DataStack { - parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses. - returns: the result of the the query. The type of the return value is specified by the generic type of the `Select` parameter. */ + @warn_unused_result public func queryValue(from: From, _ selectClause: Select, _ queryClauses: QueryClause...) -> U? { CoreStore.assert( @@ -308,6 +323,7 @@ public extension DataStack { - parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses. - returns: the result of the the query. The type of the return value is specified by the generic type of the `Select` parameter. */ + @warn_unused_result public func queryValue(from: From, _ selectClause: Select, _ queryClauses: [QueryClause]) -> U? { CoreStore.assert( @@ -328,6 +344,7 @@ public extension DataStack { - parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses. - returns: the result of the the query. The type of the return value is specified by the generic type of the `Select` parameter. */ + @warn_unused_result public func queryAttributes(from: From, _ selectClause: Select, _ queryClauses: QueryClause...) -> [[NSString: AnyObject]]? { CoreStore.assert( @@ -348,6 +365,7 @@ public extension DataStack { - parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses. - returns: the result of the the query. The type of the return value is specified by the generic type of the `Select` parameter. */ + @warn_unused_result public func queryAttributes(from: From, _ selectClause: Select, _ queryClauses: [QueryClause]) -> [[NSString: AnyObject]]? { CoreStore.assert( diff --git a/CoreStore/Migrating/CoreStore+Migration.swift b/CoreStore/Migrating/CoreStore+Migration.swift index a994673..bd909b2 100644 --- a/CoreStore/Migrating/CoreStore+Migration.swift +++ b/CoreStore/Migrating/CoreStore+Migration.swift @@ -120,6 +120,7 @@ public extension CoreStore { - parameter mappingModelBundles: an optional array of bundles to search mapping model files from. If not set, defaults to the `NSBundle.allBundles()`. :return: an array of `MigrationType`s indicating the chain of migrations required for the store; or `nil` if either inspection of the store failed, or no mapping model was found/inferred. `MigrationType` acts as a `Bool` and evaluates to `false` if no migration is required, and `true` if either a lightweight or custom migration is needed. */ + @warn_unused_result public static func requiredMigrationsForSQLiteStore(fileName fileName: String, configuration: String? = nil, mappingModelBundles: [NSBundle] = NSBundle.allBundles() as [NSBundle]) throws -> [MigrationType] { return try self.defaultStack.requiredMigrationsForSQLiteStore( @@ -137,6 +138,7 @@ public extension CoreStore { - parameter mappingModelBundles: an optional array of bundles to search mapping model files from. If not set, defaults to the `NSBundle.allBundles()`. :return: a `MigrationType` indicating the type of migration required for the store; or `nil` if either inspection of the store failed, or no mapping model was found/inferred. `MigrationType` acts as a `Bool` and evaluates to `false` if no migration is required, and `true` if either a lightweight or custom migration is needed. */ + @warn_unused_result public static func requiredMigrationsForSQLiteStore(fileURL fileURL: NSURL = defaultSQLiteStoreURL, configuration: String? = nil, mappingModelBundles: [NSBundle] = NSBundle.allBundles() as [NSBundle]) throws -> [MigrationType] { return try self.defaultStack.requiredMigrationsForSQLiteStore( diff --git a/CoreStore/Migrating/DataStack+Migration.swift b/CoreStore/Migrating/DataStack+Migration.swift index eea7f81..c323860 100644 --- a/CoreStore/Migrating/DataStack+Migration.swift +++ b/CoreStore/Migrating/DataStack+Migration.swift @@ -294,6 +294,7 @@ public extension DataStack { - parameter mappingModelBundles: an optional array of bundles to search mapping model files from. If not set, defaults to the `NSBundle.allBundles()`. :return: an array of `MigrationType`s indicating the chain of migrations required for the store; or `nil` if either inspection of the store failed, or no mapping model was found/inferred. `MigrationType` acts as a `Bool` and evaluates to `false` if no migration is required, and `true` if either a lightweight or custom migration is needed. */ + @warn_unused_result public func requiredMigrationsForSQLiteStore(fileName fileName: String, configuration: String? = nil, mappingModelBundles: [NSBundle] = NSBundle.allBundles() as [NSBundle]) throws -> [MigrationType] { return try requiredMigrationsForSQLiteStore( @@ -314,6 +315,7 @@ public extension DataStack { - parameter mappingModelBundles: an optional array of bundles to search mapping model files from. If not set, defaults to the `NSBundle.allBundles()`. :return: a `MigrationType` indicating the type of migration required for the store; or `nil` if either inspection of the store failed, or no mapping model was found/inferred. `MigrationType` acts as a `Bool` and evaluates to `false` if no migration is required, and `true` if either a lightweight or custom migration is needed. */ + @warn_unused_result public func requiredMigrationsForSQLiteStore(fileURL fileURL: NSURL = defaultSQLiteStoreURL, configuration: String? = nil, mappingModelBundles: [NSBundle] = NSBundle.allBundles() as [NSBundle]) throws -> [MigrationType] { let metadata: [String : AnyObject] diff --git a/CoreStore/Observing/CoreStore+Observing.swift b/CoreStore/Observing/CoreStore+Observing.swift index b1d846b..ac234fd 100644 --- a/CoreStore/Observing/CoreStore+Observing.swift +++ b/CoreStore/Observing/CoreStore+Observing.swift @@ -39,6 +39,7 @@ public extension CoreStore { - parameter object: the `NSManagedObject` to observe changes from - returns: a `ObjectMonitor` that monitors changes to `object` */ + @warn_unused_result public static func monitorObject(object: T) -> ObjectMonitor { return self.defaultStack.monitorObject(object) @@ -51,6 +52,7 @@ public extension CoreStore { - parameter fetchClauses: a series of `FetchClause` instances for fetching the object list. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - returns: a `ListMonitor` instance that monitors changes to the list */ + @warn_unused_result public static func monitorList(from: From, _ queryClauses: FetchClause...) -> ListMonitor { return self.defaultStack.monitorList(from, queryClauses) @@ -63,6 +65,7 @@ public extension CoreStore { - parameter fetchClauses: a series of `FetchClause` instances for fetching the object list. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - returns: a `ListMonitor` instance that monitors changes to the list */ + @warn_unused_result public static func monitorList(from: From, _ queryClauses: [FetchClause]) -> ListMonitor { return self.defaultStack.monitorList(from, queryClauses) @@ -76,6 +79,7 @@ public extension CoreStore { - parameter fetchClauses: a series of `FetchClause` instances for fetching the object list. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - returns: a `ListMonitor` instance that monitors changes to the list */ + @warn_unused_result public static func monitorSectionedList(from: From, _ sectionBy: SectionBy, _ fetchClauses: FetchClause...) -> ListMonitor { return self.defaultStack.monitorSectionedList(from, sectionBy, fetchClauses) @@ -89,6 +93,7 @@ public extension CoreStore { - parameter fetchClauses: a series of `FetchClause` instances for fetching the object list. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - returns: a `ListMonitor` instance that monitors changes to the list */ + @warn_unused_result public static func monitorSectionedList(from: From, _ sectionBy: SectionBy, _ fetchClauses: [FetchClause]) -> ListMonitor { return self.defaultStack.monitorSectionedList(from, sectionBy, fetchClauses) diff --git a/CoreStore/Observing/DataStack+Observing.swift b/CoreStore/Observing/DataStack+Observing.swift index cfe081f..6cfebdc 100644 --- a/CoreStore/Observing/DataStack+Observing.swift +++ b/CoreStore/Observing/DataStack+Observing.swift @@ -40,6 +40,7 @@ public extension DataStack { - parameter object: the `NSManagedObject` to observe changes from - returns: a `ObjectMonitor` that monitors changes to `object` */ + @warn_unused_result public func monitorObject(object: T) -> ObjectMonitor { CoreStore.assert( @@ -60,6 +61,7 @@ public extension DataStack { - parameter fetchClauses: a series of `FetchClause` instances for fetching the object list. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - returns: a `ListMonitor` instance that monitors changes to the list */ + @warn_unused_result public func monitorList(from: From, _ fetchClauses: FetchClause...) -> ListMonitor { return self.monitorList(from, fetchClauses) @@ -72,6 +74,7 @@ public extension DataStack { - parameter fetchClauses: a series of `FetchClause` instances for fetching the object list. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - returns: a `ListMonitor` instance that monitors changes to the list */ + @warn_unused_result public func monitorList(from: From, _ fetchClauses: [FetchClause]) -> ListMonitor { CoreStore.assert( @@ -99,6 +102,7 @@ public extension DataStack { - parameter fetchClauses: a series of `FetchClause` instances for fetching the object list. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - returns: a `ListMonitor` instance that monitors changes to the list */ + @warn_unused_result public func monitorSectionedList(from: From, _ sectionBy: SectionBy, _ fetchClauses: FetchClause...) -> ListMonitor { return self.monitorSectionedList(from, sectionBy, fetchClauses) @@ -112,6 +116,7 @@ public extension DataStack { - parameter fetchClauses: a series of `FetchClause` instances for fetching the object list. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - returns: a `ListMonitor` instance that monitors changes to the list */ + @warn_unused_result public func monitorSectionedList(from: From, _ sectionBy: SectionBy, _ fetchClauses: [FetchClause]) -> ListMonitor { CoreStore.assert( diff --git a/CoreStore/Observing/ListMonitor.swift b/CoreStore/Observing/ListMonitor.swift index ca005d4..8ab0a0b 100644 --- a/CoreStore/Observing/ListMonitor.swift +++ b/CoreStore/Observing/ListMonitor.swift @@ -155,6 +155,7 @@ public final class ListMonitor { - returns: `true` if at least one object in any section exists, `false` otherwise */ + @warn_unused_result public func hasObjects() -> Bool { return self.numberOfObjects() > 0 @@ -166,6 +167,7 @@ public final class ListMonitor { - parameter section: the section index. Using an index outside the valid range will return `false`. - returns: `true` if at least one object in the specified section exists, `false` otherwise */ + @warn_unused_result public func hasObjectsInSection(section: Int) -> Bool { return self.numberOfObjectsInSection(safeSectionIndex: section) > 0 @@ -176,6 +178,7 @@ public final class ListMonitor { - returns: all objects in all sections */ + @warn_unused_result public func objectsInAllSections() -> [T] { return (self.fetchedResultsController.fetchedObjects as? [T]) ?? [] @@ -187,6 +190,7 @@ public final class ListMonitor { - parameter section: the section index. Using an index outside the valid range will throw an exception. - returns: all objects in the specified section */ + @warn_unused_result public func objectsInSection(section: Int) -> [T] { return (self.fetchedResultsController.sections?[section].objects as? [T]) ?? [] @@ -198,6 +202,7 @@ public final class ListMonitor { - parameter section: the section index. Using an index outside the valid range will return `nil`. - returns: all objects in the specified section */ + @warn_unused_result public func objectsInSection(safeSectionIndex section: Int) -> [T]? { return (self.fetchedResultsController.sections?[section].objects as? [T]) ?? [] @@ -208,6 +213,7 @@ public final class ListMonitor { - returns: the number of sections */ + @warn_unused_result public func numberOfSections() -> Int { return self.fetchedResultsController.sections?.count ?? 0 @@ -218,6 +224,7 @@ public final class ListMonitor { - returns: the number of objects in all sections */ + @warn_unused_result public func numberOfObjects() -> Int { return self.fetchedResultsController.fetchedObjects?.count ?? 0 @@ -229,6 +236,7 @@ public final class ListMonitor { - parameter section: the section index. Using an index outside the valid range will throw an exception. - returns: the number of objects in the specified section */ + @warn_unused_result public func numberOfObjectsInSection(section: Int) -> Int { return self.sectionInfoAtIndex(section).numberOfObjects @@ -240,6 +248,7 @@ public final class ListMonitor { - parameter section: the section index. Using an index outside the valid range will return `nil`. - returns: the number of objects in the specified section */ + @warn_unused_result public func numberOfObjectsInSection(safeSectionIndex section: Int) -> Int? { return self.sectionInfoAtIndex(safeSectionIndex: section)?.numberOfObjects @@ -251,6 +260,7 @@ public final class ListMonitor { - parameter section: the section index. Using an index outside the valid range will throw an exception. - returns: the `NSFetchedResultsSectionInfo` for the specified section */ + @warn_unused_result public func sectionInfoAtIndex(section: Int) -> NSFetchedResultsSectionInfo { return self.fetchedResultsController.sections![section] @@ -262,6 +272,7 @@ public final class ListMonitor { - parameter section: the section index. Using an index outside the valid range will return `nil`. - returns: the `NSFetchedResultsSectionInfo` for the specified section, or `nil` if the section index is out of bounds. */ + @warn_unused_result public func sectionInfoAtIndex(safeSectionIndex section: Int) -> NSFetchedResultsSectionInfo? { guard let sections = self.fetchedResultsController.sections @@ -279,6 +290,7 @@ public final class ListMonitor { - parameter object: the `NSManagedObject` to search the index of - returns: the index of the `NSManagedObject` if it exists in the `ListMonitor`'s fetched objects, or `nil` if not found. */ + @warn_unused_result public func indexOf(object: T) -> Int? { return (self.fetchedResultsController.fetchedObjects as? [T] ?? []).indexOf(object) @@ -290,6 +302,7 @@ public final class ListMonitor { - parameter object: the `NSManagedObject` to search the index of - returns: the `NSIndexPath` of the `NSManagedObject` if it exists in the `ListMonitor`'s fetched objects, or `nil` if not found. */ + @warn_unused_result public func indexPathOf(object: T) -> NSIndexPath? { return self.fetchedResultsController.indexPathForObject(object) diff --git a/CoreStore/Saving and Processing/AsynchronousDataTransaction.swift b/CoreStore/Saving and Processing/AsynchronousDataTransaction.swift index 66b13cb..20ac7e1 100644 --- a/CoreStore/Saving and Processing/AsynchronousDataTransaction.swift +++ b/CoreStore/Saving and Processing/AsynchronousDataTransaction.swift @@ -112,6 +112,7 @@ public final class AsynchronousDataTransaction: BaseDataTransaction { - parameter object: the `NSManagedObject` type to be edited - returns: an editable proxy for the specified `NSManagedObject`. */ + @warn_unused_result public override func edit(object: T?) -> T? { CoreStore.assert( @@ -129,6 +130,7 @@ public final class AsynchronousDataTransaction: BaseDataTransaction { - parameter objectID: the `NSManagedObjectID` for the object to be edited - returns: an editable proxy for the specified `NSManagedObject`. */ + @warn_unused_result public override func edit(into: Into, _ objectID: NSManagedObjectID) -> T? { CoreStore.assert( diff --git a/CoreStore/Saving and Processing/BaseDataTransaction.swift b/CoreStore/Saving and Processing/BaseDataTransaction.swift index 7ed747b..38b1e0b 100644 --- a/CoreStore/Saving and Processing/BaseDataTransaction.swift +++ b/CoreStore/Saving and Processing/BaseDataTransaction.swift @@ -104,6 +104,7 @@ public /*abstract*/ class BaseDataTransaction { - parameter object: the `NSManagedObject` type to be edited - returns: an editable proxy for the specified `NSManagedObject`. */ + @warn_unused_result public func edit(object: T?) -> T? { CoreStore.assert( @@ -124,6 +125,7 @@ public /*abstract*/ class BaseDataTransaction { - parameter objectID: the `NSManagedObjectID` for the object to be edited - returns: an editable proxy for the specified `NSManagedObject`. */ + @warn_unused_result public func edit(into: Into, _ objectID: NSManagedObjectID) -> T? { CoreStore.assert( diff --git a/CoreStore/Saving and Processing/CoreStore+Transaction.swift b/CoreStore/Saving and Processing/CoreStore+Transaction.swift index e51628f..4d98d39 100644 --- a/CoreStore/Saving and Processing/CoreStore+Transaction.swift +++ b/CoreStore/Saving and Processing/CoreStore+Transaction.swift @@ -58,6 +58,7 @@ public extension CoreStore { - returns: a `DetachedDataTransaction` instance where creates, updates, and deletes can be made. */ + @warn_unused_result public static func beginDetached() -> DetachedDataTransaction { return self.defaultStack.beginDetached() diff --git a/CoreStore/Saving and Processing/DataStack+Transaction.swift b/CoreStore/Saving and Processing/DataStack+Transaction.swift index 12c096c..4a0f6c9 100644 --- a/CoreStore/Saving and Processing/DataStack+Transaction.swift +++ b/CoreStore/Saving and Processing/DataStack+Transaction.swift @@ -66,6 +66,7 @@ public extension DataStack { - returns: a `DetachedDataTransaction` instance where creates, updates, and deletes can be made. */ + @warn_unused_result public func beginDetached() -> DetachedDataTransaction { return DetachedDataTransaction( diff --git a/CoreStore/Saving and Processing/DetachedDataTransaction.swift b/CoreStore/Saving and Processing/DetachedDataTransaction.swift index 1cf7dd0..97f150d 100644 --- a/CoreStore/Saving and Processing/DetachedDataTransaction.swift +++ b/CoreStore/Saving and Processing/DetachedDataTransaction.swift @@ -55,6 +55,7 @@ public final class DetachedDataTransaction: BaseDataTransaction { - returns: a `DetachedDataTransaction` instance where creates, updates, and deletes can be made. */ + @warn_unused_result public func beginDetached() -> DetachedDataTransaction { return DetachedDataTransaction( diff --git a/CoreStore/Saving and Processing/SynchronousDataTransaction.swift b/CoreStore/Saving and Processing/SynchronousDataTransaction.swift index e50f363..0c62795 100644 --- a/CoreStore/Saving and Processing/SynchronousDataTransaction.swift +++ b/CoreStore/Saving and Processing/SynchronousDataTransaction.swift @@ -103,6 +103,7 @@ public final class SynchronousDataTransaction: BaseDataTransaction { - parameter object: the `NSManagedObject` type to be edited - returns: an editable proxy for the specified `NSManagedObject`. */ + @warn_unused_result public override func edit(object: T?) -> T? { CoreStore.assert( @@ -120,6 +121,7 @@ public final class SynchronousDataTransaction: BaseDataTransaction { - parameter objectID: the `NSManagedObjectID` for the object to be edited - returns: an editable proxy for the specified `NSManagedObject`. */ + @warn_unused_result public override func edit(into: Into, _ objectID: NSManagedObjectID) -> T? { CoreStore.assert(