diff --git a/Sources/Internal/NotificationObserver.swift b/Sources/Internal/NotificationObserver.swift index 33c414a..b1ca9c1 100644 --- a/Sources/Internal/NotificationObserver.swift +++ b/Sources/Internal/NotificationObserver.swift @@ -36,14 +36,14 @@ internal final class NotificationObserver { let object: AnyObject? let observer: NSObjectProtocol - init(notificationName: String, object: AnyObject?, closure: (note: NSNotification) -> Void) { + init(notificationName: String, object: AnyObject?, queue: NSOperationQueue? = nil, closure: (note: NSNotification) -> Void) { self.notificationName = notificationName self.object = object self.observer = NSNotificationCenter.defaultCenter().addObserverForName( notificationName, object: object, - queue: nil, + queue: queue, usingBlock: closure ) } diff --git a/Sources/Observing/ListMonitor.swift b/Sources/Observing/ListMonitor.swift index 811d4c1..9b835bd 100644 --- a/Sources/Observing/ListMonitor.swift +++ b/Sources/Observing/ListMonitor.swift @@ -1123,6 +1123,7 @@ public final class ListMonitor: Hashable { self.observerForWillChangePersistentStore = NotificationObserver( notificationName: NSPersistentStoreCoordinatorStoresWillChangeNotification, object: coordinator, + queue: NSOperationQueue.mainQueue(), closure: { [weak self] (note) -> Void in guard let `self` = self else { @@ -1144,6 +1145,7 @@ public final class ListMonitor: Hashable { self.observerForDidChangePersistentStore = NotificationObserver( notificationName: NSPersistentStoreCoordinatorStoresDidChangeNotification, object: coordinator, + queue: NSOperationQueue.mainQueue(), closure: { [weak self] (note) -> Void in guard let `self` = self else {