hanleyhansen/PromNight — pull request #3 by Abizern (2012-04-19 21:16:10+00:00)
Title: Use an NSFetchedResultsController to populate a tableview in a popupview.

Okay; a couple of changes.

- You can use the app in one of the portrait modes, but not landscape.
- Rather than adding a table view as a subview (which doesn't look nice) I've created a popup view on the button to show the table.
- Rather than have the main view controller handle the tableview delegate and data source methods. I've created a separate table view controller. Firstly, you need to create a view controller to give to the popup view controller, and secondly, don't be scared of view controllers. If you're showing a standalone view, just create a view controller for it.
- Note how I am passing the managed object context to the table view controller. That's the proper way to do it, rather than cheating and calling back down to the AppDelegate.
- Note how I am setting the tableview controller as the FetchedResultsController delegate so that I can refresh the tableview when a new attendee is added.

Things to do.

- You might want to change the size of the popup, or use a grouped table view by the initial of the last name.
- You may have noticed that the database is not persistent. Once you terminate the app, all the attendee information goes away. The way to fix that is to move the datastore into the documents directory if there is not already a datastore in there. That way if the iPad gets turned off, or the app terminated, then the data has been persisted to disk.
- You might want to provide some method of resetting the database.

Keep working on it. Your mistake was to try and manually create a datasource by using a fetch request rather than just using the NSFetchedResultsController, which is designed to be used as the datasource for a table view.