Skip to content

Creating a model

Jeff Hurray edited this page Apr 25, 2016 · 1 revision

All models conforming to SQLiteModel have a static method called new which will create a new instance of that model and insert it into the database. Notice we don't have to set the Gross because it has a default value of 0.

let theRoom = try Movie.new([
        Movie.Title <- "The Room",
        Movie.ReleaseDate <- NSDate(timeIntervalSince1970: 144000)
    ])

The <- operator is declared in SQLite.swift and is used to create Setters which map values to columns. More info on setters can be found here

Clone this wiki locally