Get Updates By E-mail 

iphone development examples

A Quick Look At iPhone Core Data

  •  
  •  
  •  
  •  
  •  

Since posting an article about iPhone SQLite vs. Core Data, I’ve seen a large number of searches, and had a few questions e-mailed to me about Core Data.

First off, I’d like to mention that there is no easy way to import a SQLite database into core data directly although Core Data can use a SQLite database, you will have to write code to import the data and then place it into Core Data objects.  This question has come up a few times after my earlier post so I’d just like to mention this, and I’m sorry about any confusion.

Apple has some mention on how to import existing data in a Core Data database, which you can find in the Core Data Programming guide here: Importing Existing Data Into Core Data

For those looking for a comprehensive introduction you can find Apple’s Core Data Tutorial for iPhone OS here with some coding examples:  Core Data for iPhone Tutorial

Apple has also created several other great examples for using the Core Data framework, and it’s quite possible there is something that will directly suit your needs so I will run them down here:

Top Songs – An RSS parser app that display’s Apple’s top songs from iTunes, all neatly organized.  If you’re doing any sort of database driven app that uses RSS feeds then you will want to check this out.

TaggedLocations – This is another great example, and it allows you to record your current latitude, and longitude, and enter a name, it also adds the time into that description.  If you’re looking to create some time management software this can be a good starting point.  It was designed to show you how to manipulates and attributes in Core Data, and is built off the Core Data Tutorial.

CoreDataBooks – This is an example of loading a collection of books and categorizing them by author from a SQLite database.  The primary use of this example vs. the previous ones listed is that it shows you how to initialize and use a database.

PhotoLocations – I haven’t checked out this one too much, but it allows you to record the date, time, and location, and allows you to select a photo to attach to the entry from a persistent database.
 
Something else I didn’t mention is that Xcode has tools for modeling your data, you can find out about them here: XCode Data Modeling Tools

As I stated in my earlier post, the only reason why I would use SQLite in place of Core Data is because of already existing code or an already existing database.  I hope that this helps those ust getting started with it, Apple’s resources are great and I would look there first.  There are several books upcoming on the topic, and I will mention them once I get the chance to check them out.
 


  •  
  •  
  •  
  •  
  •