Data Persistance with SQL

In a previous section, I used an in-memory store to manage gas cans. Unfortunately, when the app is terminated, and then restarted, all existing data is lost. To persist this data more permanently, there are multiple techniques possible, including: Archive, Direct file i/o, Core Data, and SQL.

Apple is promoting Core Data - presumably because they believe that it's Object-Relational Mapping library will be easier for programmers than using SQL. Personally, I think it's important to code SQL instead of relying on ORM frameworks. This section will demonstrate how to swap out the old store for a new one, and this new store will leverage the SQLite library.

First, the SQLite library must be added to the project. (Do this by selecting the project in the left-hand project view, and scrolling to the libraries section. Once added, you should see this: