Update GRDBDemoiOS app to block-based database accesses.

This commit is contained in:
Gwendal Roué committed 2016-04-08 08:40:57 +02:00
1 parent 8d3796324d
commit 8bd22b545c
2 files changed
+9 -3

No files matched your search

@@ -109,7 +109,9 @@ extension PersonsViewController {
override func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
// Delete the person
let person = personsController.recordAtIndexPath(indexPath)
try! person.delete(dbQueue)
try! dbQueue.inDatabase { db in
try person.delete(db)
}
}
}
@@ -20,7 +20,9 @@ class SimplePersonsViewController: UITableViewController {
}
private func loadPersons() {
persons = Person.order(SQLColumn("score").desc, SQLColumn("name")).fetchAll(dbQueue)
persons = dbQueue.inDatabase { db in
Person.order(SQLColumn("score").desc, SQLColumn("name")).fetchAll(db)
}
}
}
@@ -103,7 +105,9 @@ extension SimplePersonsViewController {
override func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
// Delete the person
let person = persons[indexPath.row]
try! person.delete(dbQueue)
try! dbQueue.inDatabase { db in
try person.delete(db)
}
persons.removeAtIndex(indexPath.row)
tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Fade)
}