Tham khảo tài liệu 'phát triển ứng dụng cho iphone và ipad - part 23', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | Building the Editing Controllers 189 Adding and Editing Locations with the EditLocationController The user navigates to the EditLocationController by tapping the location cell on the ViewTaskController. The EditLocationController as shown in Figure 7-9 allows the user to select a location add new locations and delete existing locations. To create the EditLocationController create a new UITableviewController without a NIB called EditLocationController. Modify your new header file to create instance variables and properties to hold the context and Task objects that the parent screen will configure. You will also need to add a member variable and property for the NSFetchedResultsController that you will use to display your location list. Additionally you will need to add import directives for the Task and Location header files. The completed header file should look like Listing 7-5. FIGURE 7-9 EditLocation Controller Screen LISTING 7-5 Available for dÏÏü lMdon import UIKit x import import interface EditLocationController UITableviewController NSFetchedResultsControllerDelegate NSFetchedResultsController fetchedResultsController NSManagedObjectContext managedObjectContext Task managedTaskObject property nonatomic retain NSFetchedResultsController fetchedResultsController property nonatomic retain NSManagedObjectContext managedObjectContext property nonatomic retain Task managedTaskObject end Let s move on to the implementation file. Add an import statement for import You will use the EditTextController to add the text for newly added locations. Next synthesize the properties that you declared in the header file synthesize fetchedResultsController managedObjectContext managedTaskObject 190 I CHAPTER 7 BUILDING A CORE DATA APPLICATION Uncomment and implement the viewDidLoad method Available for download on void viewDidLoad super viewDidLoad Set up the add button