diff --git a/Observing-changes-and-notifications.md b/Observing-changes-and-notifications.md index 9b9e4f7..56498c7 100644 --- a/Observing-changes-and-notifications.md +++ b/Observing-changes-and-notifications.md @@ -37,11 +37,11 @@ While `ObjectMonitor` exposes `removeObserver(...)` as well, it only stores `wea To observe a list of objects, implement one of the `ListObserver` protocols and specify the `EntityType`: ```swift class MyViewController: UIViewController, ListObserver { - func listMonitorWillChange(monitor: ListMonitor) { + func listMonitorWillChange(_ monitor: ListMonitor) { // ... } - func listMonitorDidChange(monitor: ListMonitor) { + func listMonitorDidChange(_ monitor: ListMonitor) { // ... } } @@ -49,25 +49,25 @@ class MyViewController: UIViewController, ListObserver { Including `ListObserver`, there are 3 observer protocols you can implement depending on how detailed you need to handle a change notification: - `ListObserver`: lets you handle these callback methods: ```swift - func listMonitorWillChange(monitor: ListMonitor) + func listMonitorWillChange(_ monitor: ListMonitor) - func listMonitorDidChange(monitor: ListMonitor) + func listMonitorDidChange(_ monitor: ListMonitor) ``` - `ListObjectObserver`: in addition to `ListObserver` methods, also lets you handle object inserts, updates, and deletes: ```swift - func listMonitor(monitor: ListMonitor, didInsertObject object: MyPersonEntity, toIndexPath indexPath: NSIndexPath) + func listMonitor(_ monitor: ListMonitor, didInsertObject object: ListEntityType, toIndexPath indexPath: NSIndexPath) - func listMonitor(monitor: ListMonitor, didDeleteObject object: MyPersonEntity, fromIndexPath indexPath: NSIndexPath) + func listMonitor(_ monitor: ListMonitor, didDeleteObject object: ListEntityType, fromIndexPath indexPath: NSIndexPath) - func listMonitor(monitor: ListMonitor, didUpdateObject object: MyPersonEntity, atIndexPath indexPath: NSIndexPath) + func listMonitor(_ monitor: ListMonitor, didUpdateObject object: ListEntityType, atIndexPath indexPath: NSIndexPath) - func listMonitor(monitor: ListMonitor, didMoveObject object: MyPersonEntity, fromIndexPath: NSIndexPath, toIndexPath: NSIndexPath) + func listMonitor(_ monitor: ListMonitor, didMoveObject object: ListEntityType, fromIndexPath: NSIndexPath, toIndexPath: NSIndexPath) ``` - `ListSectionObserver`: in addition to `ListObjectObserver` methods, also lets you handle section inserts and deletes: ```swift - func listMonitor(monitor: ListMonitor, didInsertSection sectionInfo: NSFetchedResultsSectionInfo, toSectionIndex sectionIndex: Int) + func listMonitor(_ monitor: ListMonitor, didInsertSection sectionInfo: NSFetchedResultsSectionInfo, toSectionIndex sectionIndex: Int) - func listMonitor(monitor: ListMonitor, didDeleteSection sectionInfo: NSFetchedResultsSectionInfo, fromSectionIndex sectionIndex: Int) + func listMonitor(_ monitor: ListMonitor, didDeleteSection sectionInfo: NSFetchedResultsSectionInfo, fromSectionIndex sectionIndex: Int) ``` We then need to create a `ListMonitor` instance and register our `ListObserver` as an observer: