UIKit Demo Application
This demo application is a storyboard-based UIKit application, based on the MVC design pattern. For a demo application that uses Combine and SwiftUI, see GRDBCombineDemo.
The topics covered in this demo are:
- How to setup a database in an iOS app.
- How to define a simple Codable Record.
- How to track database changes and animate a table view with ValueObservation.
- How to apply the recommendations of Good Practices for Designing Record Types.
Files of interest:
-
AppDelegatecreates, on application startup, a unique instance of DatabaseQueue available for the whole application. -
AppDatabasegrants database access for the whole application. It uses DatabaseMigrator in order to setup the database schema, and ValueObservation in order to let the application observe database changes. -
Playeris a Record type, able to read and write in the database. It conforms to the standard Codable protocol in order to gain all advantages of Codable Records. It defines the database requests used by the application. -
PlayerListViewController.swift
PlayerListViewControllerdisplays the list of players. -
PlayerEditionViewController.swift
PlayerEditionViewControllercan create or edit a player, and save it in the database.