Question

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

Was it helpful?

Solution

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.

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top