mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-03-27 11:51:16 +01:00
Fixed ObjectObserver & ListObserver methods names.
@@ -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<MyPersonEntity>) {
|
||||
func listMonitorWillChange(_ monitor: ListMonitor<ListEntityType>) {
|
||||
// ...
|
||||
}
|
||||
|
||||
func listMonitorDidChange(monitor: ListMonitor<MyPersonEntity>) {
|
||||
func listMonitorDidChange(_ monitor: ListMonitor<ListEntityType>) {
|
||||
// ...
|
||||
}
|
||||
}
|
||||
@@ -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<MyPersonEntity>)
|
||||
func listMonitorWillChange(_ monitor: ListMonitor<ListEntityType>)
|
||||
|
||||
func listMonitorDidChange(monitor: ListMonitor<MyPersonEntity>)
|
||||
func listMonitorDidChange(_ monitor: ListMonitor<ListEntityType>)
|
||||
```
|
||||
- `ListObjectObserver`: in addition to `ListObserver` methods, also lets you handle object inserts, updates, and deletes:
|
||||
```swift
|
||||
func listMonitor(monitor: ListMonitor<MyPersonEntity>, didInsertObject object: MyPersonEntity, toIndexPath indexPath: NSIndexPath)
|
||||
func listMonitor(_ monitor: ListMonitor<ListEntityType>, didInsertObject object: ListEntityType, toIndexPath indexPath: NSIndexPath)
|
||||
|
||||
func listMonitor(monitor: ListMonitor<MyPersonEntity>, didDeleteObject object: MyPersonEntity, fromIndexPath indexPath: NSIndexPath)
|
||||
func listMonitor(_ monitor: ListMonitor<ListEntityType>, didDeleteObject object: ListEntityType, fromIndexPath indexPath: NSIndexPath)
|
||||
|
||||
func listMonitor(monitor: ListMonitor<MyPersonEntity>, didUpdateObject object: MyPersonEntity, atIndexPath indexPath: NSIndexPath)
|
||||
func listMonitor(_ monitor: ListMonitor<ListEntityType>, didUpdateObject object: ListEntityType, atIndexPath indexPath: NSIndexPath)
|
||||
|
||||
func listMonitor(monitor: ListMonitor<MyPersonEntity>, didMoveObject object: MyPersonEntity, fromIndexPath: NSIndexPath, toIndexPath: NSIndexPath)
|
||||
func listMonitor(_ monitor: ListMonitor<ListEntityType>, 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<MyPersonEntity>, didInsertSection sectionInfo: NSFetchedResultsSectionInfo, toSectionIndex sectionIndex: Int)
|
||||
func listMonitor(_ monitor: ListMonitor<ListEntityType>, didInsertSection sectionInfo: NSFetchedResultsSectionInfo, toSectionIndex sectionIndex: Int)
|
||||
|
||||
func listMonitor(monitor: ListMonitor<MyPersonEntity>, didDeleteSection sectionInfo: NSFetchedResultsSectionInfo, fromSectionIndex sectionIndex: Int)
|
||||
func listMonitor(_ monitor: ListMonitor<ListEntityType>, didDeleteSection sectionInfo: NSFetchedResultsSectionInfo, fromSectionIndex sectionIndex: Int)
|
||||
```
|
||||
|
||||
We then need to create a `ListMonitor` instance and register our `ListObserver` as an observer:
|
||||
|
||||
Reference in New Issue
Block a user