2.7 KiB
UIKit Demo Application
This demo application is a storyboard-based UIKit application. For a demo application that uses Combine + SwiftUI, see GRDBCombineDemo, and for Async/Await + SwiftUI, see GRDBAsyncDemo.
Requirements: iOS 15.0+ / Xcode 12+
Note
: This demo app is not a project template. Do not copy it as a starting point for your application. Instead, create a new project, choose a GRDB installation method, and use the demo as an inspiration.
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 Recommended Practices for Designing Record Types.
Files of interest:
-
AppDatabaseis the type that grants database access. It uses DatabaseMigrator in order to setup the database schema, and ValueObservation in order to let the application observe database changes. -
This file defines the
AppDatabaseinstance used by the application. -
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. -
- Test the database schema
- Test the
Playerrecord and its requests - Test the
AppDatabasemethods that let the app access the database.