End of Iteration 1

Since my last post I updated Fort Collins for Kids to use Core Data. Core Data is an Apple-provided framework that wraps SQLite with an object-relational wrapper. Using Core Data, I created an entity called Attraction.

Note the addition of the orderingValue attribute. This lets me persist the order of the Attractions in the list. The end result of this is a database table with the same structure as my Attraction object. I add code to save this into a database, and I finally can store my edits!

The only downside was all the elaborate code that I wrote to handle the cancel and OK buttons and the DetailViewController (as documented in past blog posts) needed to be removed. With Core Data, it’s no longer possible to create Attractions that are not part of the data store, which was a key part of that design. I went back to using a boolean to determine if the Attraction is a new one. The logic of the DetailViewController is now as follows:

  • Create New Attraction

    • Initialize: create new database row, pass this new Attraction to DetailViewController
    • OK: Copy values from View into Attraction object
    • Cancel: Delete newly added Attraction
  • Edit Existing Attraction

    • Initialize: Pass Attraction to DetailViewController
    • OK: Copy values from View into Attraction object
    • Cancel: Do nothing

Let’s recap where I am:

  • Can create new Attraction objects
  • Can edit existing Attraction objects
  • Can delete Attraction objects
  • Can reorder Attraction objects in the list
  • Can store all of these changes to disk
  • Can reload the Attraction list into the application from disk

It took longer than expected, but I’ve finished everything I set out to do with Iteration 1.

My last step was the rename the application. As you may have figured out by now, this is not the application that I’ll put in the AppStore. I don’t want users editing Attractions! Instead, this application’s job is to create and edit a database file that will work with the real application. So this application has been renamed Fort Collins for Kids Editor.

Coming up… Iteration 2!

One Reply to “End of Iteration 1”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.