WIP: segfault

This commit is contained in:
John Rommel Estropia
2016-07-20 08:12:04 +09:00
parent f486ace437
commit 267c21063a
129 changed files with 2205 additions and 3282 deletions

View File

@@ -40,7 +40,7 @@ public extension CoreStore {
- returns: a `ObjectMonitor` that monitors changes to `object`
*/
@warn_unused_result
public static func monitorObject<T: NSManagedObject>(object: T) -> ObjectMonitor<T> {
public static func monitorObject<T: NSManagedObject>(_ object: T) -> ObjectMonitor<T> {
return self.defaultStack.monitorObject(object)
}
@@ -53,7 +53,7 @@ public extension CoreStore {
- returns: a `ListMonitor` instance that monitors changes to the list
*/
@warn_unused_result
public static func monitorList<T: NSManagedObject>(from: From<T>, _ fetchClauses: FetchClause...) -> ListMonitor<T> {
public static func monitorList<T: NSManagedObject>(_ from: From<T>, _ fetchClauses: FetchClause...) -> ListMonitor<T> {
return self.defaultStack.monitorList(from, fetchClauses)
}
@@ -66,7 +66,7 @@ public extension CoreStore {
- returns: a `ListMonitor` instance that monitors changes to the list
*/
@warn_unused_result
public static func monitorList<T: NSManagedObject>(from: From<T>, _ fetchClauses: [FetchClause]) -> ListMonitor<T> {
public static func monitorList<T: NSManagedObject>(_ from: From<T>, _ fetchClauses: [FetchClause]) -> ListMonitor<T> {
return self.defaultStack.monitorList(from, fetchClauses)
}
@@ -78,7 +78,7 @@ public extension CoreStore {
- parameter from: a `From` clause indicating the entity type
- parameter fetchClauses: a series of `FetchClause` instances for fetching the object list. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
*/
public static func monitorList<T: NSManagedObject>(createAsynchronously createAsynchronously: (ListMonitor<T>) -> Void, _ from: From<T>, _ fetchClauses: FetchClause...) {
public static func monitorList<T: NSManagedObject>(createAsynchronously: (ListMonitor<T>) -> Void, _ from: From<T>, _ fetchClauses: FetchClause...) {
self.defaultStack.monitorList(createAsynchronously: createAsynchronously, from, fetchClauses)
}
@@ -90,7 +90,7 @@ public extension CoreStore {
- parameter from: a `From` clause indicating the entity type
- parameter fetchClauses: a series of `FetchClause` instances for fetching the object list. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
*/
public static func monitorList<T: NSManagedObject>(createAsynchronously createAsynchronously: (ListMonitor<T>) -> Void, _ from: From<T>, _ fetchClauses: [FetchClause]) {
public static func monitorList<T: NSManagedObject>(createAsynchronously: (ListMonitor<T>) -> Void, _ from: From<T>, _ fetchClauses: [FetchClause]) {
self.defaultStack.monitorList(createAsynchronously: createAsynchronously, from, fetchClauses)
}
@@ -104,7 +104,7 @@ public extension CoreStore {
- 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> {
public static func monitorSectionedList<T: NSManagedObject>(_ from: From<T>, _ sectionBy: SectionBy, _ fetchClauses: FetchClause...) -> ListMonitor<T> {
return self.defaultStack.monitorSectionedList(from, sectionBy, fetchClauses)
}
@@ -118,7 +118,7 @@ public extension CoreStore {
- 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> {
public static func monitorSectionedList<T: NSManagedObject>(_ from: From<T>, _ sectionBy: SectionBy, _ fetchClauses: [FetchClause]) -> ListMonitor<T> {
return self.defaultStack.monitorSectionedList(from, sectionBy, fetchClauses)
}
@@ -131,7 +131,7 @@ public extension CoreStore {
- parameter sectionBy: a `SectionBy` clause indicating the keyPath for the attribute to use when sorting the list into sections.
- parameter fetchClauses: a series of `FetchClause` instances for fetching the object list. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
*/
public static func monitorSectionedList<T: NSManagedObject>(createAsynchronously createAsynchronously: (ListMonitor<T>) -> Void, _ from: From<T>, _ sectionBy: SectionBy, _ fetchClauses: FetchClause...) {
public static func monitorSectionedList<T: NSManagedObject>(createAsynchronously: (ListMonitor<T>) -> Void, _ from: From<T>, _ sectionBy: SectionBy, _ fetchClauses: FetchClause...) {
self.defaultStack.monitorSectionedList(createAsynchronously: createAsynchronously, from, sectionBy, fetchClauses)
}
@@ -144,7 +144,7 @@ public extension CoreStore {
- parameter sectionBy: a `SectionBy` clause indicating the keyPath for the attribute to use when sorting the list into sections.
- parameter fetchClauses: a series of `FetchClause` instances for fetching the object list. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
*/
public static func monitorSectionedList<T: NSManagedObject>(createAsynchronously createAsynchronously: (ListMonitor<T>) -> Void, _ from: From<T>, _ sectionBy: SectionBy, _ fetchClauses: [FetchClause]) {
public static func monitorSectionedList<T: NSManagedObject>(createAsynchronously: (ListMonitor<T>) -> Void, _ from: From<T>, _ sectionBy: SectionBy, _ fetchClauses: [FetchClause]) {
self.defaultStack.monitorSectionedList(createAsynchronously: createAsynchronously, from, sectionBy, fetchClauses)
}

View File

@@ -43,10 +43,10 @@ public extension DataStack {
- returns: a `ObjectMonitor` that monitors changes to `object`
*/
@warn_unused_result
public func monitorObject<T: NSManagedObject>(object: T) -> ObjectMonitor<T> {
public func monitorObject<T: NSManagedObject>(_ object: T) -> ObjectMonitor<T> {
CoreStore.assert(
NSThread.isMainThread(),
Thread.isMainThread,
"Attempted to observe objects from \(cs_typeName(self)) outside the main thread."
)
return ObjectMonitor(dataStack: self, object: object)
@@ -60,7 +60,7 @@ public extension DataStack {
- 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> {
public func monitorList<T: NSManagedObject>(_ from: From<T>, _ fetchClauses: FetchClause...) -> ListMonitor<T> {
return self.monitorList(from, fetchClauses)
}
@@ -73,10 +73,10 @@ public extension DataStack {
- 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> {
public func monitorList<T: NSManagedObject>(_ from: From<T>, _ fetchClauses: [FetchClause]) -> ListMonitor<T> {
CoreStore.assert(
NSThread.isMainThread(),
Thread.isMainThread,
"Attempted to observe objects from \(cs_typeName(self)) outside the main thread."
)
return ListMonitor(
@@ -89,7 +89,7 @@ public extension DataStack {
CoreStore.assert(
fetchRequest.sortDescriptors?.isEmpty == false,
"An \(cs_typeName(NSFetchedResultsController)) requires a sort information. Specify from a \(cs_typeName(OrderBy)) clause or any custom \(cs_typeName(FetchClause)) that provides a sort descriptor."
"An \(cs_typeName(ListMonitor<T>.self)) requires a sort information. Specify from a \(cs_typeName(OrderBy.self)) clause or any custom \(cs_typeName(FetchClause.self)) that provides a sort descriptor."
)
}
)
@@ -102,7 +102,7 @@ public extension DataStack {
- parameter from: a `From` clause indicating the entity type
- parameter fetchClauses: a series of `FetchClause` instances for fetching the object list. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
*/
public func monitorList<T: NSManagedObject>(createAsynchronously createAsynchronously: (ListMonitor<T>) -> Void, _ from: From<T>, _ fetchClauses: FetchClause...) {
public func monitorList<T: NSManagedObject>(createAsynchronously: (ListMonitor<T>) -> Void, _ from: From<T>, _ fetchClauses: FetchClause...) {
self.monitorList(createAsynchronously: createAsynchronously, from, fetchClauses)
}
@@ -114,10 +114,10 @@ public extension DataStack {
- parameter from: a `From` clause indicating the entity type
- parameter fetchClauses: a series of `FetchClause` instances for fetching the object list. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
*/
public func monitorList<T: NSManagedObject>(createAsynchronously createAsynchronously: (ListMonitor<T>) -> Void, _ from: From<T>, _ fetchClauses: [FetchClause]) {
public func monitorList<T: NSManagedObject>(createAsynchronously: (ListMonitor<T>) -> Void, _ from: From<T>, _ fetchClauses: [FetchClause]) {
CoreStore.assert(
NSThread.isMainThread(),
Thread.isMainThread,
"Attempted to observe objects from \(cs_typeName(self)) outside the main thread."
)
_ = ListMonitor(
@@ -130,7 +130,7 @@ public extension DataStack {
CoreStore.assert(
fetchRequest.sortDescriptors?.isEmpty == false,
"An \(cs_typeName(NSFetchedResultsController)) requires a sort information. Specify from a \(cs_typeName(OrderBy)) clause or any custom \(cs_typeName(FetchClause)) that provides a sort descriptor."
"An \(cs_typeName(ListMonitor<T>.self)) requires a sort information. Specify from a \(cs_typeName(OrderBy.self)) clause or any custom \(cs_typeName(FetchClause.self)) that provides a sort descriptor."
)
},
createAsynchronously: createAsynchronously
@@ -146,7 +146,7 @@ public extension DataStack {
- 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> {
public func monitorSectionedList<T: NSManagedObject>(_ from: From<T>, _ sectionBy: SectionBy, _ fetchClauses: FetchClause...) -> ListMonitor<T> {
return self.monitorSectionedList(from, sectionBy, fetchClauses)
}
@@ -160,10 +160,10 @@ public extension DataStack {
- 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> {
public func monitorSectionedList<T: NSManagedObject>(_ from: From<T>, _ sectionBy: SectionBy, _ fetchClauses: [FetchClause]) -> ListMonitor<T> {
CoreStore.assert(
NSThread.isMainThread(),
Thread.isMainThread,
"Attempted to observe objects from \(cs_typeName(self)) outside the main thread."
)
@@ -177,7 +177,7 @@ public extension DataStack {
CoreStore.assert(
fetchRequest.sortDescriptors?.isEmpty == false,
"An \(cs_typeName(NSFetchedResultsController)) requires a sort information. Specify from a \(cs_typeName(OrderBy)) clause or any custom \(cs_typeName(FetchClause)) that provides a sort descriptor."
"An \(cs_typeName(ListMonitor<T>.self)) requires a sort information. Specify from a \(cs_typeName(OrderBy.self)) clause or any custom \(cs_typeName(FetchClause.self)) that provides a sort descriptor."
)
}
)
@@ -191,7 +191,7 @@ public extension DataStack {
- parameter sectionBy: a `SectionBy` clause indicating the keyPath for the attribute to use when sorting the list into sections.
- parameter fetchClauses: a series of `FetchClause` instances for fetching the object list. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
*/
public func monitorSectionedList<T: NSManagedObject>(createAsynchronously createAsynchronously: (ListMonitor<T>) -> Void, _ from: From<T>, _ sectionBy: SectionBy, _ fetchClauses: FetchClause...) {
public func monitorSectionedList<T: NSManagedObject>(createAsynchronously: (ListMonitor<T>) -> Void, _ from: From<T>, _ sectionBy: SectionBy, _ fetchClauses: FetchClause...) {
self.monitorSectionedList(createAsynchronously: createAsynchronously, from, sectionBy, fetchClauses)
}
@@ -204,10 +204,10 @@ public extension DataStack {
- parameter sectionBy: a `SectionBy` clause indicating the keyPath for the attribute to use when sorting the list into sections.
- parameter fetchClauses: a series of `FetchClause` instances for fetching the object list. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
*/
public func monitorSectionedList<T: NSManagedObject>(createAsynchronously createAsynchronously: (ListMonitor<T>) -> Void, _ from: From<T>, _ sectionBy: SectionBy, _ fetchClauses: [FetchClause]) {
public func monitorSectionedList<T: NSManagedObject>(createAsynchronously: (ListMonitor<T>) -> Void, _ from: From<T>, _ sectionBy: SectionBy, _ fetchClauses: [FetchClause]) {
CoreStore.assert(
NSThread.isMainThread(),
Thread.isMainThread,
"Attempted to observe objects from \(cs_typeName(self)) outside the main thread."
)
@@ -221,7 +221,7 @@ public extension DataStack {
CoreStore.assert(
fetchRequest.sortDescriptors?.isEmpty == false,
"An \(cs_typeName(NSFetchedResultsController)) requires a sort information. Specify from a \(cs_typeName(OrderBy)) clause or any custom \(cs_typeName(FetchClause)) that provides a sort descriptor."
"An \(cs_typeName(ListMonitor<T>.self)) requires a sort information. Specify from a \(cs_typeName(OrderBy.self)) clause or any custom \(cs_typeName(FetchClause.self)) that provides a sort descriptor."
)
},
createAsynchronously: createAsynchronously

View File

@@ -111,7 +111,7 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
*/
public subscript(sectionIndex: Int, itemIndex: Int) -> T {
return self[NSIndexPath(indexes: [sectionIndex, itemIndex], length: 2)]
return self[NSIndexPath(indexes: [sectionIndex, itemIndex], length: 2) as IndexPath]
}
/**
@@ -140,13 +140,13 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
- parameter indexPath: the `NSIndexPath` for the object. Using an `indexPath` with an invalid range will raise an exception.
- returns: the `NSManagedObject` at the specified index path
*/
public subscript(indexPath: NSIndexPath) -> T {
public subscript(indexPath: IndexPath) -> T {
CoreStore.assert(
!self.isPendingRefetch || NSThread.isMainThread(),
!self.isPendingRefetch || Thread.isMainThread,
"Attempted to access a \(cs_typeName(self)) outside the main thread while a refetch is in progress."
)
return self.fetchedResultsController.objectAtIndexPath(indexPath) as! T
return self.fetchedResultsController.object(at: indexPath) as! T
}
/**
@@ -155,11 +155,11 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
- parameter indexPath: the `NSIndexPath` for the object. Using an `indexPath` with an invalid range will return `nil`.
- returns: the `NSManagedObject` at the specified index path, or `nil` if out of bounds
*/
public subscript(safeIndexPath indexPath: NSIndexPath) -> T? {
public subscript(safeIndexPath indexPath: IndexPath) -> T? {
return self[
safeSectionIndex: indexPath.indexAtPosition(0),
safeItemIndex: indexPath.indexAtPosition(1)
safeSectionIndex: indexPath[0],
safeItemIndex: indexPath[1]
]
}
@@ -192,7 +192,7 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
- returns: `true` if at least one object in the specified section exists, `false` otherwise
*/
@warn_unused_result
public func hasObjectsInSection(section: Int) -> Bool {
public func hasObjectsInSection(_ section: Int) -> Bool {
return self.numberOfObjectsInSection(safeSectionIndex: section) > 0
}
@@ -206,7 +206,7 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
public func objectsInAllSections() -> [T] {
CoreStore.assert(
!self.isPendingRefetch || NSThread.isMainThread(),
!self.isPendingRefetch || Thread.isMainThread,
"Attempted to access a \(cs_typeName(self)) outside the main thread while a refetch is in progress."
)
return (self.fetchedResultsController.fetchedObjects as? [T]) ?? []
@@ -219,7 +219,7 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
- returns: all objects in the specified section
*/
@warn_unused_result
public func objectsInSection(section: Int) -> [T] {
public func objectsInSection(_ section: Int) -> [T] {
return (self.sectionInfoAtIndex(section).objects as? [T]) ?? []
}
@@ -245,7 +245,7 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
public func numberOfSections() -> Int {
CoreStore.assert(
!self.isPendingRefetch || NSThread.isMainThread(),
!self.isPendingRefetch || Thread.isMainThread,
"Attempted to access a \(cs_typeName(self)) outside the main thread while a refetch is in progress."
)
return self.fetchedResultsController.sections?.count ?? 0
@@ -260,7 +260,7 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
public func numberOfObjects() -> Int {
CoreStore.assert(
!self.isPendingRefetch || NSThread.isMainThread(),
!self.isPendingRefetch || Thread.isMainThread,
"Attempted to access a \(cs_typeName(self)) outside the main thread while a refetch is in progress."
)
return self.fetchedResultsController.fetchedObjects?.count ?? 0
@@ -273,7 +273,7 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
- returns: the number of objects in the specified section
*/
@warn_unused_result
public func numberOfObjectsInSection(section: Int) -> Int {
public func numberOfObjectsInSection(_ section: Int) -> Int {
return self.sectionInfoAtIndex(section).numberOfObjects
}
@@ -297,10 +297,10 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
- returns: the `NSFetchedResultsSectionInfo` for the specified section
*/
@warn_unused_result
public func sectionInfoAtIndex(section: Int) -> NSFetchedResultsSectionInfo {
public func sectionInfoAtIndex(_ section: Int) -> NSFetchedResultsSectionInfo {
CoreStore.assert(
!self.isPendingRefetch || NSThread.isMainThread(),
!self.isPendingRefetch || Thread.isMainThread,
"Attempted to access a \(cs_typeName(self)) outside the main thread while a refetch is in progress."
)
return self.fetchedResultsController.sections![section]
@@ -316,7 +316,7 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
public func sectionInfoAtIndex(safeSectionIndex section: Int) -> NSFetchedResultsSectionInfo? {
CoreStore.assert(
!self.isPendingRefetch || NSThread.isMainThread(),
!self.isPendingRefetch || Thread.isMainThread,
"Attempted to access a \(cs_typeName(self)) outside the main thread while a refetch is in progress."
)
guard section >= 0 else {
@@ -340,7 +340,7 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
public func sections() -> [NSFetchedResultsSectionInfo] {
CoreStore.assert(
!self.isPendingRefetch || NSThread.isMainThread(),
!self.isPendingRefetch || Thread.isMainThread,
"Attempted to access a \(cs_typeName(self)) outside the main thread while a refetch is in progress."
)
return self.fetchedResultsController.sections ?? []
@@ -354,13 +354,13 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
- returns: the target section for the specified "Section Index" title and index.
*/
@warn_unused_result
public func targetSectionForSectionIndex(title title: String, index: Int) -> Int {
public func targetSectionForSectionIndex(title: String, index: Int) -> Int {
CoreStore.assert(
!self.isPendingRefetch || NSThread.isMainThread(),
!self.isPendingRefetch || Thread.isMainThread,
"Attempted to access a \(cs_typeName(self)) outside the main thread while a refetch is in progress."
)
return self.fetchedResultsController.sectionForSectionIndexTitle(title, atIndex: index)
return self.fetchedResultsController.section(forSectionIndexTitle: title, at: index)
}
/**
@@ -372,7 +372,7 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
public func sectionIndexTitles() -> [String] {
CoreStore.assert(
!self.isPendingRefetch || NSThread.isMainThread(),
!self.isPendingRefetch || Thread.isMainThread,
"Attempted to access a \(cs_typeName(self)) outside the main thread while a refetch is in progress."
)
return self.fetchedResultsController.sectionIndexTitles
@@ -385,13 +385,13 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
- 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? {
public func indexOf(_ object: T) -> Int? {
CoreStore.assert(
!self.isPendingRefetch || NSThread.isMainThread(),
!self.isPendingRefetch || Thread.isMainThread,
"Attempted to access a \(cs_typeName(self)) outside the main thread while a refetch is in progress."
)
return (self.fetchedResultsController.fetchedObjects as? [T] ?? []).indexOf(object)
return (self.fetchedResultsController.fetchedObjects as? [T] ?? []).index(of: object)
}
/**
@@ -401,13 +401,13 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
- 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? {
public func indexPathOf(_ object: T) -> IndexPath? {
CoreStore.assert(
!self.isPendingRefetch || NSThread.isMainThread(),
!self.isPendingRefetch || Thread.isMainThread,
"Attempted to access a \(cs_typeName(self)) outside the main thread while a refetch is in progress."
)
return self.fetchedResultsController.indexPathForObject(object)
return self.fetchedResultsController.indexPath(forObject: object)
}
@@ -424,7 +424,7 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
- parameter observer: a `ListObserver` to send change notifications to
*/
public func addObserver<U: ListObserver where U.ListEntityType == T>(observer: U) {
public func addObserver<U: ListObserver where U.ListEntityType == T>(_ observer: U) {
self.unregisterObserver(observer)
self.registerObserver(
@@ -459,7 +459,7 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
- parameter observer: a `ListObjectObserver` to send change notifications to
*/
public func addObserver<U: ListObjectObserver where U.ListEntityType == T>(observer: U) {
public func addObserver<U: ListObjectObserver where U.ListEntityType == T>(_ observer: U) {
self.unregisterObserver(observer)
self.registerObserver(
@@ -513,7 +513,7 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
- parameter observer: a `ListSectionObserver` to send change notifications to
*/
public func addObserver<U: ListSectionObserver where U.ListEntityType == T>(observer: U) {
public func addObserver<U: ListSectionObserver where U.ListEntityType == T>(_ observer: U) {
self.unregisterObserver(observer)
self.registerObserver(
@@ -574,7 +574,7 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
- parameter observer: a `ListObserver` to unregister notifications to
*/
public func removeObserver<U: ListObserver where U.ListEntityType == T>(observer: U) {
public func removeObserver<U: ListObserver where U.ListEntityType == T>(_ observer: U) {
self.unregisterObserver(observer)
}
@@ -594,7 +594,7 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
- parameter fetchClauses: a series of `FetchClause` instances for fetching the object list. Accepts `Where`, `OrderBy`, and `Tweak` clauses. Note that only specified clauses will be changed; unspecified clauses will use previous values.
*/
public func refetch(fetchClauses: FetchClause...) {
public func refetch(_ fetchClauses: FetchClause...) {
self.refetch(fetchClauses)
}
@@ -606,7 +606,7 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
- parameter fetchClauses: a series of `FetchClause` instances for fetching the object list. Accepts `Where`, `OrderBy`, and `Tweak` clauses. Note that only specified clauses will be changed; unspecified clauses will use previous values.
*/
public func refetch(fetchClauses: [FetchClause]) {
public func refetch(_ fetchClauses: [FetchClause]) {
self.refetch { (fetchRequest) in
@@ -625,7 +625,7 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
// MARK: Internal
internal convenience init(dataStack: DataStack, from: From<T>, sectionBy: SectionBy?, applyFetchClauses: (fetchRequest: NSFetchRequest) -> Void) {
internal convenience init(dataStack: DataStack, from: From<T>, sectionBy: SectionBy?, applyFetchClauses: (fetchRequest: NSFetchRequest<NSManagedObject>) -> Void) {
self.init(
context: dataStack.mainContext,
@@ -637,7 +637,7 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
)
}
internal convenience init(dataStack: DataStack, from: From<T>, sectionBy: SectionBy?, applyFetchClauses: (fetchRequest: NSFetchRequest) -> Void, createAsynchronously: (ListMonitor<T>) -> Void) {
internal convenience init(dataStack: DataStack, from: From<T>, sectionBy: SectionBy?, applyFetchClauses: (fetchRequest: NSFetchRequest<NSManagedObject>) -> Void, createAsynchronously: (ListMonitor<T>) -> Void) {
self.init(
context: dataStack.mainContext,
@@ -649,7 +649,7 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
)
}
internal convenience init(unsafeTransaction: UnsafeDataTransaction, from: From<T>, sectionBy: SectionBy?, applyFetchClauses: (fetchRequest: NSFetchRequest) -> Void) {
internal convenience init(unsafeTransaction: UnsafeDataTransaction, from: From<T>, sectionBy: SectionBy?, applyFetchClauses: (fetchRequest: NSFetchRequest<NSManagedObject>) -> Void) {
self.init(
context: unsafeTransaction.context,
@@ -661,7 +661,7 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
)
}
internal convenience init(unsafeTransaction: UnsafeDataTransaction, from: From<T>, sectionBy: SectionBy?, applyFetchClauses: (fetchRequest: NSFetchRequest) -> Void, createAsynchronously: (ListMonitor<T>) -> Void) {
internal convenience init(unsafeTransaction: UnsafeDataTransaction, from: From<T>, sectionBy: SectionBy?, applyFetchClauses: (fetchRequest: NSFetchRequest<NSManagedObject>) -> Void, createAsynchronously: (ListMonitor<T>) -> Void) {
self.init(
context: unsafeTransaction.context,
@@ -675,10 +675,10 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
internal func upcast() -> ListMonitor<NSManagedObject> {
return unsafeBitCast(self, ListMonitor<NSManagedObject>.self)
return unsafeBitCast(self, to: ListMonitor<NSManagedObject>.self)
}
internal func registerChangeNotification(notificationKey: UnsafePointer<Void>, name: String, toObserver observer: AnyObject, callback: (monitor: ListMonitor<T>) -> Void) {
internal func registerChangeNotification(_ notificationKey: UnsafePointer<Void>, name: String, toObserver observer: AnyObject, callback: (monitor: ListMonitor<T>) -> Void) {
cs_setAssociatedRetainedObject(
NotificationObserver(
@@ -698,7 +698,7 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
)
}
internal func registerObjectNotification(notificationKey: UnsafePointer<Void>, name: String, toObserver observer: AnyObject, callback: (monitor: ListMonitor<T>, object: T, indexPath: NSIndexPath?, newIndexPath: NSIndexPath?) -> Void) {
internal func registerObjectNotification(_ notificationKey: UnsafePointer<Void>, name: String, toObserver observer: AnyObject, callback: (monitor: ListMonitor<T>, object: T, indexPath: IndexPath?, newIndexPath: IndexPath?) -> Void) {
cs_setAssociatedRetainedObject(
NotificationObserver(
@@ -707,7 +707,7 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
closure: { [weak self] (note) -> Void in
guard let `self` = self,
let userInfo = note.userInfo,
let userInfo = (note as NSNotification).userInfo,
let object = userInfo[UserInfoKeyObject] as? T else {
return
@@ -715,8 +715,8 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
callback(
monitor: self,
object: object,
indexPath: userInfo[UserInfoKeyIndexPath] as? NSIndexPath,
newIndexPath: userInfo[UserInfoKeyNewIndexPath] as? NSIndexPath
indexPath: userInfo[UserInfoKeyIndexPath] as? IndexPath,
newIndexPath: userInfo[UserInfoKeyNewIndexPath] as? IndexPath
)
}
),
@@ -725,7 +725,7 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
)
}
internal func registerSectionNotification(notificationKey: UnsafePointer<Void>, name: String, toObserver observer: AnyObject, callback: (monitor: ListMonitor<T>, sectionInfo: NSFetchedResultsSectionInfo, sectionIndex: Int) -> Void) {
internal func registerSectionNotification(_ notificationKey: UnsafePointer<Void>, name: String, toObserver observer: AnyObject, callback: (monitor: ListMonitor<T>, sectionInfo: NSFetchedResultsSectionInfo, sectionIndex: Int) -> Void) {
cs_setAssociatedRetainedObject(
NotificationObserver(
@@ -734,9 +734,9 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
closure: { [weak self] (note) -> Void in
guard let `self` = self,
let userInfo = note.userInfo,
let userInfo = (note as NSNotification).userInfo,
let sectionInfo = userInfo[UserInfoKeySectionInfo] as? NSFetchedResultsSectionInfo,
let sectionIndex = (userInfo[UserInfoKeySectionIndex] as? NSNumber)?.integerValue else {
let sectionIndex = (userInfo[UserInfoKeySectionIndex] as? NSNumber)?.intValue else {
return
}
@@ -752,10 +752,10 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
)
}
internal func registerObserver<U: AnyObject>(observer: U, willChange: (observer: U, monitor: ListMonitor<T>) -> Void, didChange: (observer: U, monitor: ListMonitor<T>) -> Void, willRefetch: (observer: U, monitor: ListMonitor<T>) -> Void, didRefetch: (observer: U, monitor: ListMonitor<T>) -> Void) {
internal func registerObserver<U: AnyObject>(_ observer: U, willChange: (observer: U, monitor: ListMonitor<T>) -> Void, didChange: (observer: U, monitor: ListMonitor<T>) -> Void, willRefetch: (observer: U, monitor: ListMonitor<T>) -> Void, didRefetch: (observer: U, monitor: ListMonitor<T>) -> Void) {
CoreStore.assert(
NSThread.isMainThread(),
Thread.isMainThread,
"Attempted to add an observer of type \(cs_typeName(observer)) outside the main thread."
)
self.registerChangeNotification(
@@ -812,10 +812,10 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
)
}
internal func registerObserver<U: AnyObject>(observer: U, didInsertObject: (observer: U, monitor: ListMonitor<T>, object: T, toIndexPath: NSIndexPath) -> Void, didDeleteObject: (observer: U, monitor: ListMonitor<T>, object: T, fromIndexPath: NSIndexPath) -> Void, didUpdateObject: (observer: U, monitor: ListMonitor<T>, object: T, atIndexPath: NSIndexPath) -> Void, didMoveObject: (observer: U, monitor: ListMonitor<T>, object: T, fromIndexPath: NSIndexPath, toIndexPath: NSIndexPath) -> Void) {
internal func registerObserver<U: AnyObject>(_ observer: U, didInsertObject: (observer: U, monitor: ListMonitor<T>, object: T, toIndexPath: IndexPath) -> Void, didDeleteObject: (observer: U, monitor: ListMonitor<T>, object: T, fromIndexPath: IndexPath) -> Void, didUpdateObject: (observer: U, monitor: ListMonitor<T>, object: T, atIndexPath: IndexPath) -> Void, didMoveObject: (observer: U, monitor: ListMonitor<T>, object: T, fromIndexPath: IndexPath, toIndexPath: IndexPath) -> Void) {
CoreStore.assert(
NSThread.isMainThread(),
Thread.isMainThread,
"Attempted to add an observer of type \(cs_typeName(observer)) outside the main thread."
)
@@ -894,10 +894,10 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
)
}
internal func registerObserver<U: AnyObject>(observer: U, didInsertSection: (observer: U, monitor: ListMonitor<T>, sectionInfo: NSFetchedResultsSectionInfo, toIndex: Int) -> Void, didDeleteSection: (observer: U, monitor: ListMonitor<T>, sectionInfo: NSFetchedResultsSectionInfo, fromIndex: Int) -> Void) {
internal func registerObserver<U: AnyObject>(_ observer: U, didInsertSection: (observer: U, monitor: ListMonitor<T>, sectionInfo: NSFetchedResultsSectionInfo, toIndex: Int) -> Void, didDeleteSection: (observer: U, monitor: ListMonitor<T>, sectionInfo: NSFetchedResultsSectionInfo, fromIndex: Int) -> Void) {
CoreStore.assert(
NSThread.isMainThread(),
Thread.isMainThread,
"Attempted to add an observer of type \(cs_typeName(observer)) outside the main thread."
)
@@ -939,10 +939,10 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
)
}
internal func unregisterObserver(observer: AnyObject) {
internal func unregisterObserver(_ observer: AnyObject) {
CoreStore.assert(
NSThread.isMainThread(),
Thread.isMainThread,
"Attempted to remove an observer of type \(cs_typeName(observer)) outside the main thread."
)
let nilValue: AnyObject? = nil
@@ -960,10 +960,10 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
cs_setAssociatedRetainedObject(nilValue, forKey: &self.didDeleteSectionKey, inObject: observer)
}
internal func refetch(applyFetchClauses: (fetchRequest: NSFetchRequest) -> Void) {
internal func refetch(_ applyFetchClauses: (fetchRequest: NSFetchRequest<NSManagedObject>) -> Void) {
CoreStore.assert(
NSThread.isMainThread(),
Thread.isMainThread,
"Attempted to refetch a \(cs_typeName(self)) outside the main thread."
)
@@ -971,14 +971,14 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
self.isPendingRefetch = true
NSNotificationCenter.defaultCenter().postNotificationName(
ListMonitorWillRefetchListNotification,
NotificationCenter.default.post(
name: Notification.Name(rawValue: ListMonitorWillRefetchListNotification),
object: self
)
}
self.applyFetchClauses = applyFetchClauses
self.taskGroup.notify(.Main) { [weak self] () -> Void in
self.taskGroup.notify(.main) { [weak self] () -> Void in
guard let `self` = self else {
@@ -997,7 +997,7 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
try! self.fetchedResultsController.performFetchFromSpecifiedStores()
GCDQueue.Main.async { [weak self] () -> Void in
GCDQueue.main.async { [weak self] () -> Void in
guard let `self` = self else {
@@ -1007,8 +1007,8 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
self.fetchedResultsControllerDelegate.enabled = true
self.isPendingRefetch = false
NSNotificationCenter.defaultCenter().postNotificationName(
ListMonitorDidRefetchListNotification,
NotificationCenter.default.post(
name: NSNotification.Name(rawValue: ListMonitorDidRefetchListNotification),
object: self
)
}
@@ -1039,13 +1039,13 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
private var didDeleteSectionKey: Void?
private let fetchedResultsController: CoreStoreFetchedResultsController
private let fetchedResultsControllerDelegate: FetchedResultsControllerDelegate
private let fetchedResultsControllerDelegate: FetchedResultsControllerDelegate<T>
private let sectionIndexTransformer: (sectionName: KeyPath?) -> String?
private var observerForWillChangePersistentStore: NotificationObserver!
private var observerForDidChangePersistentStore: NotificationObserver!
private let taskGroup = GCDGroup()
private let transactionQueue: GCDQueue
private var applyFetchClauses: (fetchRequest: NSFetchRequest) -> Void
private var applyFetchClauses: (fetchRequest: NSFetchRequest<NSManagedObject>) -> Void
private var isPersistentStoreChanging: Bool = false {
@@ -1068,24 +1068,24 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
}
}
private init(context: NSManagedObjectContext, transactionQueue: GCDQueue, from: From<T>, sectionBy: SectionBy?, applyFetchClauses: (fetchRequest: NSFetchRequest) -> Void, createAsynchronously: ((ListMonitor<T>) -> Void)?) {
private init(context: NSManagedObjectContext, transactionQueue: GCDQueue, from: From<T>, sectionBy: SectionBy?, applyFetchClauses: (fetchRequest: NSFetchRequest<NSManagedObject>) -> Void, createAsynchronously: ((ListMonitor<T>) -> Void)?) {
let fetchRequest = CoreStoreFetchRequest()
let fetchRequest = CoreStoreFetchRequest<T>()
fetchRequest.fetchLimit = 0
fetchRequest.resultType = .ManagedObjectResultType
fetchRequest.resultType = .managedObjectResultType
fetchRequest.fetchBatchSize = 20
fetchRequest.includesPendingChanges = false
fetchRequest.shouldRefreshRefetchedObjects = true
let fetchedResultsController = CoreStoreFetchedResultsController(
context: context,
fetchRequest: fetchRequest,
fetchRequest: fetchRequest.dynamicCast(),
from: from,
sectionBy: sectionBy,
applyFetchClauses: applyFetchClauses
)
let fetchedResultsControllerDelegate = FetchedResultsControllerDelegate()
let fetchedResultsControllerDelegate = FetchedResultsControllerDelegate<T>()
self.fetchedResultsController = fetchedResultsController
self.fetchedResultsControllerDelegate = fetchedResultsControllerDelegate
@@ -1110,9 +1110,9 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
}
self.observerForWillChangePersistentStore = NotificationObserver(
notificationName: NSPersistentStoreCoordinatorStoresWillChangeNotification,
notificationName: NSNotification.Name.NSPersistentStoreCoordinatorStoresWillChange.rawValue,
object: coordinator,
queue: NSOperationQueue.mainQueue(),
queue: OperationQueue.main,
closure: { [weak self] (note) -> Void in
guard let `self` = self else {
@@ -1123,7 +1123,7 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
self.isPersistentStoreChanging = true
guard let removedStores = (note.userInfo?[NSRemovedPersistentStoresKey] as? [NSPersistentStore]).flatMap(Set.init)
where !Set(self.fetchedResultsController.fetchRequest.affectedStores ?? []).intersect(removedStores).isEmpty else {
where !Set(self.fetchedResultsController.fetchRequest.affectedStores ?? []).intersection(removedStores).isEmpty else {
return
}
@@ -1132,9 +1132,9 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
)
self.observerForDidChangePersistentStore = NotificationObserver(
notificationName: NSPersistentStoreCoordinatorStoresDidChangeNotification,
notificationName: NSNotification.Name.NSPersistentStoreCoordinatorStoresDidChange.rawValue,
object: coordinator,
queue: NSOperationQueue.mainQueue(),
queue: OperationQueue.main,
closure: { [weak self] (note) -> Void in
guard let `self` = self else {
@@ -1146,7 +1146,7 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
let previousStores = Set(self.fetchedResultsController.fetchRequest.affectedStores ?? [])
let currentStores = previousStores
.subtract(note.userInfo?[NSRemovedPersistentStoresKey] as? [NSPersistentStore] ?? [])
.subtracting(note.userInfo?[NSRemovedPersistentStoresKey] as? [NSPersistentStore] ?? [])
.union(note.userInfo?[NSAddedPersistentStoresKey] as? [NSPersistentStore] ?? [])
if previousStores != currentStores {
@@ -1164,7 +1164,7 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
transactionQueue.async {
try! fetchedResultsController.performFetchFromSpecifiedStores()
self.taskGroup.notify(.Main) {
self.taskGroup.notify(.main) {
createAsynchronously(self)
}
@@ -1213,13 +1213,13 @@ extension ListMonitor: FetchedResultsControllerHandler {
// MARK: FetchedResultsControllerHandler
internal func controller(controller: NSFetchedResultsController, didChangeObject anObject: AnyObject, atIndexPath indexPath: NSIndexPath?, forChangeType type: NSFetchedResultsChangeType, newIndexPath: NSIndexPath?) {
internal func controller(_ controller: NSFetchedResultsController<NSFetchRequestResult>, didChangeObject anObject: AnyObject, atIndexPath indexPath: IndexPath?, forChangeType type: NSFetchedResultsChangeType, newIndexPath: IndexPath?) {
switch type {
case .Insert:
NSNotificationCenter.defaultCenter().postNotificationName(
ListMonitorDidInsertObjectNotification,
case .insert:
NotificationCenter.default.post(
name: Notification.Name(rawValue: ListMonitorDidInsertObjectNotification),
object: self,
userInfo: [
UserInfoKeyObject: anObject,
@@ -1227,9 +1227,9 @@ extension ListMonitor: FetchedResultsControllerHandler {
]
)
case .Delete:
NSNotificationCenter.defaultCenter().postNotificationName(
ListMonitorDidDeleteObjectNotification,
case .delete:
NotificationCenter.default.post(
name: Notification.Name(rawValue: ListMonitorDidDeleteObjectNotification),
object: self,
userInfo: [
UserInfoKeyObject: anObject,
@@ -1237,9 +1237,9 @@ extension ListMonitor: FetchedResultsControllerHandler {
]
)
case .Update:
NSNotificationCenter.defaultCenter().postNotificationName(
ListMonitorDidUpdateObjectNotification,
case .update:
NotificationCenter.default.post(
name: Notification.Name(rawValue: ListMonitorDidUpdateObjectNotification),
object: self,
userInfo: [
UserInfoKeyObject: anObject,
@@ -1247,9 +1247,9 @@ extension ListMonitor: FetchedResultsControllerHandler {
]
)
case .Move:
NSNotificationCenter.defaultCenter().postNotificationName(
ListMonitorDidMoveObjectNotification,
case .move:
NotificationCenter.default.post(
name: Notification.Name(rawValue: ListMonitorDidMoveObjectNotification),
object: self,
userInfo: [
UserInfoKeyObject: anObject,
@@ -1260,27 +1260,27 @@ extension ListMonitor: FetchedResultsControllerHandler {
}
}
internal func controller(controller: NSFetchedResultsController, didChangeSection sectionInfo: NSFetchedResultsSectionInfo, atIndex sectionIndex: Int, forChangeType type: NSFetchedResultsChangeType) {
internal func controller(_ controller: NSFetchedResultsController<NSFetchRequestResult>, didChangeSection sectionInfo: NSFetchedResultsSectionInfo, atIndex sectionIndex: Int, forChangeType type: NSFetchedResultsChangeType) {
switch type {
case .Insert:
NSNotificationCenter.defaultCenter().postNotificationName(
ListMonitorDidInsertSectionNotification,
case .insert:
NotificationCenter.default.post(
name: Notification.Name(rawValue: ListMonitorDidInsertSectionNotification),
object: self,
userInfo: [
UserInfoKeySectionInfo: sectionInfo,
UserInfoKeySectionIndex: NSNumber(integer: sectionIndex)
UserInfoKeySectionIndex: NSNumber(value: sectionIndex)
]
)
case .Delete:
NSNotificationCenter.defaultCenter().postNotificationName(
ListMonitorDidDeleteSectionNotification,
case .delete:
NotificationCenter.default.post(
name: Notification.Name(rawValue: ListMonitorDidDeleteSectionNotification),
object: self,
userInfo: [
UserInfoKeySectionInfo: sectionInfo,
UserInfoKeySectionIndex: NSNumber(integer: sectionIndex)
UserInfoKeySectionIndex: NSNumber(value: sectionIndex)
]
)
@@ -1289,25 +1289,25 @@ extension ListMonitor: FetchedResultsControllerHandler {
}
}
internal func controllerWillChangeContent(controller: NSFetchedResultsController) {
internal func controllerWillChangeContent(_ controller: NSFetchedResultsController<NSFetchRequestResult>) {
self.taskGroup.enter()
NSNotificationCenter.defaultCenter().postNotificationName(
ListMonitorWillChangeListNotification,
NotificationCenter.default.post(
name: Notification.Name(rawValue: ListMonitorWillChangeListNotification),
object: self
)
}
internal func controllerDidChangeContent(controller: NSFetchedResultsController) {
internal func controllerDidChangeContent(_ controller: NSFetchedResultsController<NSFetchRequestResult>) {
NSNotificationCenter.defaultCenter().postNotificationName(
ListMonitorDidChangeListNotification,
NotificationCenter.default.post(
name: Notification.Name(rawValue: ListMonitorDidChangeListNotification),
object: self
)
self.taskGroup.leave()
}
internal func controller(controller: NSFetchedResultsController, sectionIndexTitleForSectionName sectionName: String?) -> String? {
internal func controller(_ controller: NSFetchedResultsController<NSFetchRequestResult>, sectionIndexTitleForSectionName sectionName: String?) -> String? {
return self.sectionIndexTransformer(sectionName: sectionName)
}

View File

@@ -53,28 +53,28 @@ public protocol ListObserver: class {
- parameter monitor: the `ListMonitor` monitoring the list being observed
*/
func listMonitorWillChange(monitor: ListMonitor<ListEntityType>)
func listMonitorWillChange(_ monitor: ListMonitor<ListEntityType>)
/**
Handles processing right after a change to the observed list occurs
- parameter monitor: the `ListMonitor` monitoring the object being observed
*/
func listMonitorDidChange(monitor: ListMonitor<ListEntityType>)
func listMonitorDidChange(_ monitor: ListMonitor<ListEntityType>)
/**
This method is broadcast from within the `ListMonitor`'s `refetch(...)` method to let observers prepare for the internal `NSFetchedResultsController`'s pending change to its predicate, sort descriptors, etc. Note that the actual refetch will happen after the `NSFetchedResultsController`'s last `controllerDidChangeContent(_:)` notification completes.
- parameter monitor: the `ListMonitor` monitoring the object being observed
*/
func listMonitorWillRefetch(monitor: ListMonitor<ListEntityType>)
func listMonitorWillRefetch(_ monitor: ListMonitor<ListEntityType>)
/**
After the `ListMonitor`'s `refetch(...)` method is called, this method is broadcast after the `NSFetchedResultsController`'s last `controllerDidChangeContent(_:)` notification completes.
- parameter monitor: the `ListMonitor` monitoring the object being observed
*/
func listMonitorDidRefetch(monitor: ListMonitor<ListEntityType>)
func listMonitorDidRefetch(_ monitor: ListMonitor<ListEntityType>)
}
@@ -85,22 +85,22 @@ public extension ListObserver {
/**
The default implementation does nothing.
*/
func listMonitorWillChange(monitor: ListMonitor<ListEntityType>) { }
func listMonitorWillChange(_ monitor: ListMonitor<ListEntityType>) { }
/**
The default implementation does nothing.
*/
func listMonitorDidChange(monitor: ListMonitor<ListEntityType>) { }
func listMonitorDidChange(_ monitor: ListMonitor<ListEntityType>) { }
/**
The default implementation does nothing.
*/
func listMonitorWillRefetch(monitor: ListMonitor<ListEntityType>) { }
func listMonitorWillRefetch(_ monitor: ListMonitor<ListEntityType>) { }
/**
The default implementation does nothing.
*/
func listMonitorDidRefetch(monitor: ListMonitor<ListEntityType>) { }
func listMonitorDidRefetch(_ monitor: ListMonitor<ListEntityType>) { }
}
@@ -125,7 +125,7 @@ public protocol ListObjectObserver: ListObserver {
- parameter object: the entity type for the inserted object
- parameter indexPath: the new `NSIndexPath` for the inserted object
*/
func listMonitor(monitor: ListMonitor<ListEntityType>, didInsertObject object: ListEntityType, toIndexPath indexPath: NSIndexPath)
func listMonitor(_ monitor: ListMonitor<ListEntityType>, didInsertObject object: ListEntityType, toIndexPath indexPath: IndexPath)
/**
Notifies that an object was deleted from the specified `NSIndexPath` in the list
@@ -134,7 +134,7 @@ public protocol ListObjectObserver: ListObserver {
- parameter object: the entity type for the deleted object
- parameter indexPath: the `NSIndexPath` for the deleted object
*/
func listMonitor(monitor: ListMonitor<ListEntityType>, didDeleteObject object: ListEntityType, fromIndexPath indexPath: NSIndexPath)
func listMonitor(_ monitor: ListMonitor<ListEntityType>, didDeleteObject object: ListEntityType, fromIndexPath indexPath: IndexPath)
/**
Notifies that an object at the specified `NSIndexPath` was updated
@@ -143,7 +143,7 @@ public protocol ListObjectObserver: ListObserver {
- parameter object: the entity type for the updated object
- parameter indexPath: the `NSIndexPath` for the updated object
*/
func listMonitor(monitor: ListMonitor<ListEntityType>, didUpdateObject object: ListEntityType, atIndexPath indexPath: NSIndexPath)
func listMonitor(_ monitor: ListMonitor<ListEntityType>, didUpdateObject object: ListEntityType, atIndexPath indexPath: IndexPath)
/**
Notifies that an object's index changed
@@ -153,7 +153,7 @@ public protocol ListObjectObserver: ListObserver {
- parameter fromIndexPath: the previous `NSIndexPath` for the moved object
- parameter toIndexPath: the new `NSIndexPath` for the moved object
*/
func listMonitor(monitor: ListMonitor<ListEntityType>, didMoveObject object: ListEntityType, fromIndexPath: NSIndexPath, toIndexPath: NSIndexPath)
func listMonitor(_ monitor: ListMonitor<ListEntityType>, didMoveObject object: ListEntityType, fromIndexPath: IndexPath, toIndexPath: IndexPath)
}
@@ -164,22 +164,22 @@ public extension ListObjectObserver {
/**
The default implementation does nothing.
*/
func listMonitor(monitor: ListMonitor<ListEntityType>, didInsertObject object: ListEntityType, toIndexPath indexPath: NSIndexPath) { }
func listMonitor(_ monitor: ListMonitor<ListEntityType>, didInsertObject object: ListEntityType, toIndexPath indexPath: IndexPath) { }
/**
The default implementation does nothing.
*/
func listMonitor(monitor: ListMonitor<ListEntityType>, didDeleteObject object: ListEntityType, fromIndexPath indexPath: NSIndexPath) { }
func listMonitor(_ monitor: ListMonitor<ListEntityType>, didDeleteObject object: ListEntityType, fromIndexPath indexPath: IndexPath) { }
/**
The default implementation does nothing.
*/
func listMonitor(monitor: ListMonitor<ListEntityType>, didUpdateObject object: ListEntityType, atIndexPath indexPath: NSIndexPath) { }
func listMonitor(_ monitor: ListMonitor<ListEntityType>, didUpdateObject object: ListEntityType, atIndexPath indexPath: IndexPath) { }
/**
The default implementation does nothing.
*/
func listMonitor(monitor: ListMonitor<ListEntityType>, didMoveObject object: ListEntityType, fromIndexPath: NSIndexPath, toIndexPath: NSIndexPath) { }
func listMonitor(_ monitor: ListMonitor<ListEntityType>, didMoveObject object: ListEntityType, fromIndexPath: IndexPath, toIndexPath: IndexPath) { }
}
@@ -205,7 +205,7 @@ public protocol ListSectionObserver: ListObjectObserver {
- parameter sectionInfo: the `NSFetchedResultsSectionInfo` for the inserted section
- parameter sectionIndex: the new section index for the new section
*/
func listMonitor(monitor: ListMonitor<ListEntityType>, didInsertSection sectionInfo: NSFetchedResultsSectionInfo, toSectionIndex sectionIndex: Int)
func listMonitor(_ monitor: ListMonitor<ListEntityType>, didInsertSection sectionInfo: NSFetchedResultsSectionInfo, toSectionIndex sectionIndex: Int)
/**
Notifies that a section was inserted at the specified index
@@ -214,7 +214,7 @@ public protocol ListSectionObserver: ListObjectObserver {
- parameter sectionInfo: the `NSFetchedResultsSectionInfo` for the deleted section
- parameter sectionIndex: the previous section index for the deleted section
*/
func listMonitor(monitor: ListMonitor<ListEntityType>, didDeleteSection sectionInfo: NSFetchedResultsSectionInfo, fromSectionIndex sectionIndex: Int)
func listMonitor(_ monitor: ListMonitor<ListEntityType>, didDeleteSection sectionInfo: NSFetchedResultsSectionInfo, fromSectionIndex sectionIndex: Int)
}
@@ -225,12 +225,12 @@ public extension ListSectionObserver {
/**
The default implementation does nothing.
*/
func listMonitor(monitor: ListMonitor<ListEntityType>, didInsertSection sectionInfo: NSFetchedResultsSectionInfo, toSectionIndex sectionIndex: Int) { }
func listMonitor(_ monitor: ListMonitor<ListEntityType>, didInsertSection sectionInfo: NSFetchedResultsSectionInfo, toSectionIndex sectionIndex: Int) { }
/**
The default implementation does nothing.
*/
func listMonitor(monitor: ListMonitor<ListEntityType>, didDeleteSection sectionInfo: NSFetchedResultsSectionInfo, fromSectionIndex sectionIndex: Int) { }
func listMonitor(_ monitor: ListMonitor<ListEntityType>, didDeleteSection sectionInfo: NSFetchedResultsSectionInfo, fromSectionIndex sectionIndex: Int) { }
}
#endif

View File

@@ -44,14 +44,14 @@ import CoreData
Observers registered via `addObserver(_:)` are not retained. `ObjectMonitor` only keeps a `weak` reference to all observers, thus keeping itself free from retain-cycles.
*/
public final class ObjectMonitor<T: NSManagedObject> {
public final class ObjectMonitor<EntityType: NSManagedObject> {
/**
Returns the `NSManagedObject` instance being observed, or `nil` if the object was already deleted.
*/
public var object: T? {
public var object: EntityType? {
return self.fetchedResultsController.fetchedObjects?.first as? T
return self.fetchedResultsController.fetchedObjects?.first as? EntityType
}
/**
@@ -73,7 +73,7 @@ public final class ObjectMonitor<T: NSManagedObject> {
- parameter observer: an `ObjectObserver` to send change notifications to
*/
public func addObserver<U: ObjectObserver where U.ObjectEntityType == T>(observer: U) {
public func addObserver<U: ObjectObserver where U.ObjectEntityType == EntityType>(_ observer: U) {
self.unregisterObserver(observer)
self.registerObserver(
@@ -100,7 +100,7 @@ public final class ObjectMonitor<T: NSManagedObject> {
- parameter observer: an `ObjectObserver` to unregister notifications to
*/
public func removeObserver<U: ObjectObserver where U.ObjectEntityType == T>(observer: U) {
public func removeObserver<U: ObjectObserver where U.ObjectEntityType == EntityType>(_ observer: U) {
self.unregisterObserver(observer)
}
@@ -116,21 +116,21 @@ public final class ObjectMonitor<T: NSManagedObject> {
// MARK: Internal
internal convenience init(dataStack: DataStack, object: T) {
internal convenience init(dataStack: DataStack, object: EntityType) {
self.init(context: dataStack.mainContext, object: object)
}
internal convenience init(unsafeTransaction: UnsafeDataTransaction, object: T) {
internal convenience init(unsafeTransaction: UnsafeDataTransaction, object: EntityType) {
self.init(context: unsafeTransaction.context, object: object)
}
internal func registerObserver<U: AnyObject>(observer: U, willChangeObject: (observer: U, monitor: ObjectMonitor<T>, object: T) -> Void, didDeleteObject: (observer: U, monitor: ObjectMonitor<T>, object: T) -> Void, didUpdateObject: (observer: U, monitor: ObjectMonitor<T>, object: T, changedPersistentKeys: Set<String>) -> Void) {
internal func registerObserver<U: AnyObject>(_ observer: U, willChangeObject: (observer: U, monitor: ObjectMonitor<EntityType>, object: EntityType) -> Void, didDeleteObject: (observer: U, monitor: ObjectMonitor<EntityType>, object: EntityType) -> Void, didUpdateObject: (observer: U, monitor: ObjectMonitor<EntityType>, object: EntityType, changedPersistentKeys: Set<String>) -> Void) {
CoreStore.assert(
NSThread.isMainThread(),
"Attempted to add an observer of type \(cs_typeName(observer)) outside the main thread."
Thread.isMainThread,
"Attempted to add an observer of type \(cs_typeName(observer as AnyObject)) outside the main thread."
)
self.registerChangeNotification(
&self.willChangeObjectKey,
@@ -170,7 +170,7 @@ public final class ObjectMonitor<T: NSManagedObject> {
}
let previousCommitedAttributes = self.lastCommittedAttributes
let currentCommitedAttributes = object.committedValuesForKeys(nil) as! [String: NSObject]
let currentCommitedAttributes = object.committedValues(forKeys: nil) as! [String: NSObject]
var changedKeys = Set<String>()
for key in currentCommitedAttributes.keys {
@@ -192,10 +192,10 @@ public final class ObjectMonitor<T: NSManagedObject> {
)
}
internal func unregisterObserver(observer: AnyObject) {
internal func unregisterObserver(_ observer: AnyObject) {
CoreStore.assert(
NSThread.isMainThread(),
Thread.isMainThread,
"Attempted to remove an observer of type \(cs_typeName(observer)) outside the main thread."
)
@@ -207,7 +207,7 @@ public final class ObjectMonitor<T: NSManagedObject> {
internal func upcast() -> ObjectMonitor<NSManagedObject> {
return unsafeBitCast(self, ObjectMonitor<NSManagedObject>.self)
return unsafeBitCast(self, to: ObjectMonitor<NSManagedObject>.self)
}
deinit {
@@ -219,19 +219,19 @@ public final class ObjectMonitor<T: NSManagedObject> {
// MARK: Private
private let fetchedResultsController: CoreStoreFetchedResultsController
private let fetchedResultsControllerDelegate: FetchedResultsControllerDelegate
private let fetchedResultsControllerDelegate: FetchedResultsControllerDelegate<EntityType>
private var lastCommittedAttributes = [String: NSObject]()
private var willChangeObjectKey: Void?
private var didDeleteObjectKey: Void?
private var didUpdateObjectKey: Void?
private init(context: NSManagedObjectContext, object: T) {
private init(context: NSManagedObjectContext, object: EntityType) {
let fetchRequest = CoreStoreFetchRequest()
let fetchRequest = CoreStoreFetchRequest<EntityType>()
fetchRequest.entity = object.entity
fetchRequest.fetchLimit = 0
fetchRequest.resultType = .ManagedObjectResultType
fetchRequest.resultType = .managedObjectResultType
fetchRequest.sortDescriptors = []
fetchRequest.includesPendingChanges = false
fetchRequest.shouldRefreshRefetchedObjects = true
@@ -239,11 +239,11 @@ public final class ObjectMonitor<T: NSManagedObject> {
let objectID = object.objectID
let fetchedResultsController = CoreStoreFetchedResultsController(
context: context,
fetchRequest: fetchRequest,
fetchRequest: fetchRequest.dynamicCast(),
applyFetchClauses: Where("SELF", isEqualTo: objectID).applyToFetchRequest
)
let fetchedResultsControllerDelegate = FetchedResultsControllerDelegate()
let fetchedResultsControllerDelegate = FetchedResultsControllerDelegate<EntityType>()
self.fetchedResultsController = fetchedResultsController
self.fetchedResultsControllerDelegate = fetchedResultsControllerDelegate
@@ -252,10 +252,10 @@ public final class ObjectMonitor<T: NSManagedObject> {
fetchedResultsControllerDelegate.fetchedResultsController = fetchedResultsController
try! fetchedResultsController.performFetchFromSpecifiedStores()
self.lastCommittedAttributes = (self.object?.committedValuesForKeys(nil) as? [String: NSObject]) ?? [:]
self.lastCommittedAttributes = (self.object?.committedValues(forKeys: nil) as? [String: NSObject]) ?? [:]
}
private func registerChangeNotification(notificationKey: UnsafePointer<Void>, name: String, toObserver observer: AnyObject, callback: (monitor: ObjectMonitor<T>) -> Void) {
private func registerChangeNotification(_ notificationKey: UnsafePointer<Void>, name: String, toObserver observer: AnyObject, callback: (monitor: ObjectMonitor<EntityType>) -> Void) {
cs_setAssociatedRetainedObject(
NotificationObserver(
@@ -275,7 +275,7 @@ public final class ObjectMonitor<T: NSManagedObject> {
)
}
private func registerObjectNotification(notificationKey: UnsafePointer<Void>, name: String, toObserver observer: AnyObject, callback: (monitor: ObjectMonitor<T>, object: T) -> Void) {
private func registerObjectNotification(_ notificationKey: UnsafePointer<Void>, name: String, toObserver observer: AnyObject, callback: (monitor: ObjectMonitor<EntityType>, object: EntityType) -> Void) {
cs_setAssociatedRetainedObject(
NotificationObserver(
@@ -284,8 +284,8 @@ public final class ObjectMonitor<T: NSManagedObject> {
closure: { [weak self] (note) -> Void in
guard let `self` = self,
let userInfo = note.userInfo,
let object = userInfo[UserInfoKeyObject] as? T else {
let userInfo = (note as NSNotification).userInfo,
let object = userInfo[UserInfoKeyObject] as? EntityType else {
return
}
@@ -320,30 +320,30 @@ extension ObjectMonitor: FetchedResultsControllerHandler {
// MARK: FetchedResultsControllerHandler
internal func controllerWillChangeContent(controller: NSFetchedResultsController) {
internal func controllerWillChangeContent(_ controller: NSFetchedResultsController<NSFetchRequestResult>) {
NSNotificationCenter.defaultCenter().postNotificationName(
ObjectMonitorWillChangeObjectNotification,
NotificationCenter.default.post(
name: Notification.Name(rawValue: ObjectMonitorWillChangeObjectNotification),
object: self
)
}
internal func controllerDidChangeContent(controller: NSFetchedResultsController) { }
internal func controllerDidChangeContent(_ controller: NSFetchedResultsController<NSFetchRequestResult>) { }
internal func controller(controller: NSFetchedResultsController, didChangeObject anObject: AnyObject, atIndexPath indexPath: NSIndexPath?, forChangeType type: NSFetchedResultsChangeType, newIndexPath: NSIndexPath?) {
internal func controller(_ controller: NSFetchedResultsController<NSFetchRequestResult>, didChangeObject anObject: AnyObject, atIndexPath indexPath: IndexPath?, forChangeType type: NSFetchedResultsChangeType, newIndexPath: IndexPath?) {
switch type {
case .Delete:
NSNotificationCenter.defaultCenter().postNotificationName(
ObjectMonitorDidDeleteObjectNotification,
case .delete:
NotificationCenter.default.post(
name: Notification.Name(rawValue: ObjectMonitorDidDeleteObjectNotification),
object: self,
userInfo: [UserInfoKeyObject: anObject]
)
case .Update:
NSNotificationCenter.defaultCenter().postNotificationName(
ObjectMonitorDidUpdateObjectNotification,
case .update:
NotificationCenter.default.post(
name: Notification.Name(rawValue: ObjectMonitorDidUpdateObjectNotification),
object: self,
userInfo: [UserInfoKeyObject: anObject]
)
@@ -353,9 +353,9 @@ extension ObjectMonitor: FetchedResultsControllerHandler {
}
}
internal func controller(controller: NSFetchedResultsController, didChangeSection sectionInfo: NSFetchedResultsSectionInfo, atIndex sectionIndex: Int, forChangeType type: NSFetchedResultsChangeType) { }
internal func controller(_ controller: NSFetchedResultsController<NSFetchRequestResult>, didChangeSection sectionInfo: NSFetchedResultsSectionInfo, atIndex sectionIndex: Int, forChangeType type: NSFetchedResultsChangeType) { }
internal func controller(controller: NSFetchedResultsController, sectionIndexTitleForSectionName sectionName: String?) -> String? {
internal func controller(_ controller: NSFetchedResultsController<NSFetchRequestResult>, sectionIndexTitleForSectionName sectionName: String?) -> String? {
return sectionName
}

View File

@@ -51,7 +51,7 @@ public protocol ObjectObserver: class {
- parameter monitor: the `ObjectMonitor` monitoring the object being observed
- parameter object: the `NSManagedObject` instance being observed
*/
func objectMonitor(monitor: ObjectMonitor<ObjectEntityType>, willUpdateObject object: ObjectEntityType)
func objectMonitor(_ monitor: ObjectMonitor<ObjectEntityType>, willUpdateObject object: ObjectEntityType)
/**
Handles processing right after a change to the observed `object` occurs
@@ -60,7 +60,7 @@ public protocol ObjectObserver: class {
- parameter object: the `NSManagedObject` instance being observed
- parameter changedPersistentKeys: a `Set` of key paths for the attributes that were changed. Note that `changedPersistentKeys` only contains keys for attributes/relationships present in the persistent store, thus transient properties will not be reported.
*/
func objectMonitor(monitor: ObjectMonitor<ObjectEntityType>, didUpdateObject object: ObjectEntityType, changedPersistentKeys: Set<KeyPath>)
func objectMonitor(_ monitor: ObjectMonitor<ObjectEntityType>, didUpdateObject object: ObjectEntityType, changedPersistentKeys: Set<KeyPath>)
/**
Handles processing right after `object` is deleted
@@ -68,7 +68,7 @@ public protocol ObjectObserver: class {
- parameter monitor: the `ObjectMonitor` monitoring the object being observed
- parameter object: the `NSManagedObject` instance being observed
*/
func objectMonitor(monitor: ObjectMonitor<ObjectEntityType>, didDeleteObject object: ObjectEntityType)
func objectMonitor(_ monitor: ObjectMonitor<ObjectEntityType>, didDeleteObject object: ObjectEntityType)
}
@@ -79,17 +79,17 @@ public extension ObjectObserver {
/**
The default implementation does nothing.
*/
func objectMonitor(monitor: ObjectMonitor<ObjectEntityType>, willUpdateObject object: ObjectEntityType) { }
func objectMonitor(_ monitor: ObjectMonitor<ObjectEntityType>, willUpdateObject object: ObjectEntityType) { }
/**
The default implementation does nothing.
*/
func objectMonitor(monitor: ObjectMonitor<ObjectEntityType>, didUpdateObject object: ObjectEntityType, changedPersistentKeys: Set<KeyPath>) { }
func objectMonitor(_ monitor: ObjectMonitor<ObjectEntityType>, didUpdateObject object: ObjectEntityType, changedPersistentKeys: Set<KeyPath>) { }
/**
The default implementation does nothing.
*/
func objectMonitor(monitor: ObjectMonitor<ObjectEntityType>, didDeleteObject object: ObjectEntityType) { }
func objectMonitor(_ monitor: ObjectMonitor<ObjectEntityType>, didDeleteObject object: ObjectEntityType) { }
}
#endif

View File

@@ -43,7 +43,7 @@ public extension UnsafeDataTransaction {
- returns: a `ObjectMonitor` that monitors changes to `object`
*/
@warn_unused_result
public func monitorObject<T: NSManagedObject>(object: T) -> ObjectMonitor<T> {
public func monitorObject<T: NSManagedObject>(_ object: T) -> ObjectMonitor<T> {
return ObjectMonitor(
unsafeTransaction: self,
@@ -59,7 +59,7 @@ public extension UnsafeDataTransaction {
- 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> {
public func monitorList<T: NSManagedObject>(_ from: From<T>, _ fetchClauses: FetchClause...) -> ListMonitor<T> {
return self.monitorList(from, fetchClauses)
}
@@ -72,7 +72,7 @@ public extension UnsafeDataTransaction {
- 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> {
public func monitorList<T: NSManagedObject>(_ from: From<T>, _ fetchClauses: [FetchClause]) -> ListMonitor<T> {
CoreStore.assert(
fetchClauses.filter { $0 is OrderBy }.count > 0,
@@ -97,7 +97,7 @@ public extension UnsafeDataTransaction {
- parameter from: a `From` clause indicating the entity type
- parameter fetchClauses: a series of `FetchClause` instances for fetching the object list. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
*/
public func monitorList<T: NSManagedObject>(createAsynchronously createAsynchronously: (ListMonitor<T>) -> Void, _ from: From<T>, _ fetchClauses: FetchClause...) {
public func monitorList<T: NSManagedObject>(createAsynchronously: (ListMonitor<T>) -> Void, _ from: From<T>, _ fetchClauses: FetchClause...) {
self.monitorList(createAsynchronously: createAsynchronously, from, fetchClauses)
}
@@ -109,7 +109,7 @@ public extension UnsafeDataTransaction {
- parameter from: a `From` clause indicating the entity type
- parameter fetchClauses: a series of `FetchClause` instances for fetching the object list. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
*/
public func monitorList<T: NSManagedObject>(createAsynchronously createAsynchronously: (ListMonitor<T>) -> Void, _ from: From<T>, _ fetchClauses: [FetchClause]) {
public func monitorList<T: NSManagedObject>(createAsynchronously: (ListMonitor<T>) -> Void, _ from: From<T>, _ fetchClauses: [FetchClause]) {
CoreStore.assert(
fetchClauses.filter { $0 is OrderBy }.count > 0,
@@ -137,7 +137,7 @@ public extension UnsafeDataTransaction {
- 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> {
public func monitorSectionedList<T: NSManagedObject>(_ from: From<T>, _ sectionBy: SectionBy, _ fetchClauses: FetchClause...) -> ListMonitor<T> {
return self.monitorSectionedList(from, sectionBy, fetchClauses)
}
@@ -151,7 +151,7 @@ public extension UnsafeDataTransaction {
- 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> {
public func monitorSectionedList<T: NSManagedObject>(_ from: From<T>, _ sectionBy: SectionBy, _ fetchClauses: [FetchClause]) -> ListMonitor<T> {
CoreStore.assert(
fetchClauses.filter { $0 is OrderBy }.count > 0,
@@ -177,7 +177,7 @@ public extension UnsafeDataTransaction {
- parameter sectionBy: a `SectionBy` clause indicating the keyPath for the attribute to use when sorting the list into sections.
- parameter fetchClauses: a series of `FetchClause` instances for fetching the object list. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
*/
public func monitorSectionedList<T: NSManagedObject>(createAsynchronously createAsynchronously: (ListMonitor<T>) -> Void, _ from: From<T>, _ sectionBy: SectionBy, _ fetchClauses: FetchClause...) {
public func monitorSectionedList<T: NSManagedObject>(createAsynchronously: (ListMonitor<T>) -> Void, _ from: From<T>, _ sectionBy: SectionBy, _ fetchClauses: FetchClause...) {
self.monitorSectionedList(createAsynchronously: createAsynchronously, from, sectionBy, fetchClauses)
}
@@ -190,7 +190,7 @@ public extension UnsafeDataTransaction {
- parameter sectionBy: a `SectionBy` clause indicating the keyPath for the attribute to use when sorting the list into sections.
- parameter fetchClauses: a series of `FetchClause` instances for fetching the object list. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
*/
public func monitorSectionedList<T: NSManagedObject>(createAsynchronously createAsynchronously: (ListMonitor<T>) -> Void, _ from: From<T>, _ sectionBy: SectionBy, _ fetchClauses: [FetchClause]) {
public func monitorSectionedList<T: NSManagedObject>(createAsynchronously: (ListMonitor<T>) -> Void, _ from: From<T>, _ sectionBy: SectionBy, _ fetchClauses: [FetchClause]) {
CoreStore.assert(
fetchClauses.filter { $0 is OrderBy }.count > 0,