Continuing to explore CoreData

A few weeks back I was at MacWorld where I talked to the people at APRESS to see what books they may have on CoreData. They had one that seemed to be pretty good and I have picked it up. The book is called Pro Core Data for iOS: Data Access and Persistence Engine for iPhone, iPad, and iPod touch by MIchael Privat and Robert Wamer. While the book only covers thru iOS4, I figure it may have a better structure and approach for understanding the basics of CoreData.

I plan on spending time over the next few months going thru this book…and will provide some feedback here on what I think of it, and if it helps me get passed my mental block on CoreData.

Core Data and iOS

I’ve been working on a new app lately, and I’ve taken this time to try and teach myself CoreData.  CoreData is the mechanism by which Apple has taken traditional SQL database and mapped it to the programming model used in iOS apps.  Over the next few blog entries I will try and describe my learning process, in the hope that it will help others pick up CoreData.  Also, I hope to start a dialog to help others, and myself, work thru any challenges which come up during this process.

If you are just starting, I find that Apple’s Core Data template app, is always a good way of understanding how it is all pulled together.  So let’s give that a shot by starting with a MasterDetail Application.  To do this, create a new Project and select Master Detail:

Master Detail


After you select that, fill in the next screen.  I have chosen to create a Universal Binary since I think you should always start from there, it exposes you to the ins and outs of MVC (Model View Controller).  Don’t forget to chose CoreData and Automatic Reference Counting.

After choosing the location for the project… give it a compile.  You should have a working CoreData application, that can render on either the iPad or iPhone simulator.

Master Detail Detail Screen


As you can see from the following screen shots both the iPad:

iPad Sample Core Data

and the iPhone:

iPhone Core Dataare working fine!

So what do we really have here? We have a simple app that if you click the plus will create a new record (date time stamp) and a detail screen that will show that time stamp.

Detail Screen

That’s pretty much it.

In the next post I will go a bit deeper on all the files that Apple created for you automatically when you chose this template.