added warn_unused_result annotations where they seem reasonable

This commit is contained in:
John Rommel Estropia
2015-08-29 22:29:03 +09:00
parent 56ea14d53c
commit 22943d2c76
15 changed files with 91 additions and 0 deletions

View File

@@ -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<T: NSManagedObject>(object: T) -> ObjectMonitor<T> {
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<T: NSManagedObject>(from: From<T>, _ queryClauses: FetchClause...) -> ListMonitor<T> {
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<T: NSManagedObject>(from: From<T>, _ queryClauses: [FetchClause]) -> ListMonitor<T> {
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<T: NSManagedObject>(from: From<T>, _ sectionBy: SectionBy, _ fetchClauses: FetchClause...) -> ListMonitor<T> {
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<T: NSManagedObject>(from: From<T>, _ sectionBy: SectionBy, _ fetchClauses: [FetchClause]) -> ListMonitor<T> {
return self.defaultStack.monitorSectionedList(from, sectionBy, fetchClauses)

View File

@@ -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<T: NSManagedObject>(object: T) -> ObjectMonitor<T> {
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<T: NSManagedObject>(from: From<T>, _ fetchClauses: FetchClause...) -> ListMonitor<T> {
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<T: NSManagedObject>(from: From<T>, _ fetchClauses: [FetchClause]) -> ListMonitor<T> {
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<T: NSManagedObject>(from: From<T>, _ sectionBy: SectionBy, _ fetchClauses: FetchClause...) -> ListMonitor<T> {
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<T: NSManagedObject>(from: From<T>, _ sectionBy: SectionBy, _ fetchClauses: [FetchClause]) -> ListMonitor<T> {
CoreStore.assert(

View File

@@ -155,6 +155,7 @@ public final class ListMonitor<T: NSManagedObject> {
- 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<T: NSManagedObject> {
- 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<T: NSManagedObject> {
- 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<T: NSManagedObject> {
- 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<T: NSManagedObject> {
- 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<T: NSManagedObject> {
- 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<T: NSManagedObject> {
- 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<T: NSManagedObject> {
- 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<T: NSManagedObject> {
- 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<T: NSManagedObject> {
- 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<T: NSManagedObject> {
- 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<T: NSManagedObject> {
- 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<T: NSManagedObject> {
- 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)