views:

277

answers:

2

Hi - My application has a simple data model with 70 read-only records grouped into six categories. Currently the persistent data is stored in an XML file which I parse on application launch, and create objects for each record which are stored in an NSMutableArray.

I then populate a UIPickerView from the objects stored in the array, and when the user selects a row in the picker, display content pulled from the same objects.

Using CoreData and SQLite would use much less code, but it seems to be designed to work with UITableViews exclusively.

Has anyone used CoreData to fetch records outside of the UITableView interface?

Thanks

jk

+3  A: 

Core Data is not designed to work with UITableViews only. Although it's really easy to Core Data with the NSFetchedResultsController to populate a table view you can still do all the fetches you want on your an.

Just make your own NSFetchRequests to get the data you want. From the list of objects, particular objects or just single values you can use this date for whatever purpose intended.

ck
To add to this, Core Data was originally developed for the Mac, where it's used for far more than just table views. For example, in my application I load and manage a complex object graph that represents a mathematical equation. This is displayed and managed using a completely custom UI.
Brad Larson
A: 

I put my custom Core Data methods into the application delegate, where they can be called from any class. To do this, I add a #define as follows:

#define UIAppDelegate ((MyAppDelegate *) [[UIApplication sharedApplication] delegate])

I can then call my methods like so:

[UIAppDelegate fetchBooks:managedObjectContext];

A UITableView is not required for any of this.

Alex Reynolds