SQLite.swift: Best way to implement model classes representing rows of a given table? SQLite.swift: Best way to implement model classes representing rows of a given table? sqlite sqlite

SQLite.swift: Best way to implement model classes representing rows of a given table?


Checkout http://github.com/groue/GRDB.swift. It provides a ready-made Record class, as well as focused protocols, that grant fetching and persistence methods to any of your custom struct or class:

let persons = Persons.fetchAll(db, ...)try Person(...).insert(db)

Update: GRDB is a protocol-oriented library, which means that it favors immutable models. This is quite unlike Core Data or Realm, and there are consequences on application design. Check out How to build an iOS application with SQLite and GRDB.swift