From e1c3dda6e072f00732a33e9b7a3a8955339cc2e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Mon, 17 Oct 2016 11:52:44 +0200 Subject: [PATCH] Documentation --- README.md | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index a98681a85..57f694d2d 100644 --- a/README.md +++ b/README.md @@ -2342,7 +2342,7 @@ When SQLite won't let you provide an explicit primary key (as in [full-text](#fu var id: Int64? init(row: Row) { - self.id = row.value(named: "rowid") + id = row.value(named: "rowid") } } ``` @@ -2351,7 +2351,7 @@ When SQLite won't let you provide an explicit primary key (as in [full-text](#fu ```swift init(row: Row) { - self.id = row.value(Column.rowID) + id = row.value(Column.rowID) } ``` @@ -4208,13 +4208,21 @@ let controller = FetchedRecordsController( #### Typical Table View Updates -You can use the `recordsWillChange` and `recordsDidChange` callbacks to bracket updates to a table view whose content is provided by the fetched records controller, as illustrated in the following example: +When a change in the fetched records should just trigger a reloading of the whole table view, you can simply tell so: + +```swift +controller.trackChanges { [unowned self] _ in + self.tableView.reloadData() +} +``` + +For animated table view updates, use the `recordsWillChange` and `recordsDidChange` callbacks to bracket events provided by the fetched records controller, as illustrated in the following example: ```swift // Assume self has a tableView property, and a configureCell(_:atIndexPath:) // method which updates the contents of a given cell. -self.controller.trackChanges( +controller.trackChanges( // controller's records are about to change: recordsWillChange: { [unowned self] _ in self.tableView.beginUpdates()