1. Trang chủ
  2. » Kỹ Thuật - Công Nghệ

a0247 wrox professional iphone split 1 5448

7 4 0

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Nội dung

ffirs.indd ii 9/17/10 6:52:52 PM PROFESSIONAL IPHONE® AND IPAD™ DATABASE APPLICATION PROGRAMMING INTRODUCTION xxiii Download from Wow! eBook PART I MANIPULATING AND DISPLAYING DATA ON THE IPHONE AND IPAD CHAPTER Introducing Data-Driven Applications CHAPTER The iPhone and iPad Database: SQLite 19 CHAPTER Displaying Your Data: The UITableView 57 CHAPTER iPad Interface Elements 89 PART II MANAGING YOUR DATA WITH CORE DATA CHAPTER Introducing Core Data 123 CHAPTER Modeling Data in Xcode 145 CHAPTER Building a Core Data Application 163 CHAPTER Core Data–Related Cocoa Features 219 CHAPTER Core Data Migration and Performance 235 PART III APPLICATION INTEGRATION USING WEB SERVICES CHAPTER 10 Working with XML on the iPhone 271 CHAPTER 11 Integrating with Web Services 301 APPENDIX A Tools for Troubleshooting Your Applications 343 INDEX 355 ffirs.indd i 9/17/10 6:52:51 PM ffirs.indd ii 9/17/10 6:52:52 PM Download from Wow! eBook PROFESSIONAL Download from Wow! eBook iPhone® and iPad™ Database Application Programming ffirs.indd iii 9/17/10 6:52:53 PM 184 ❘ CHAPTER BUILDING A CORE DATA APPLICATION Leave the numberOfSectionsInTableView method with the default implementation The table will have only one section Change the tableView:numberOfRowsInSection: method to return one row: - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1; } // Customize the number of rows in the table view - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return 1; } EditTextController.m Next, you should implement the tableView:cellForRowAtIndexPath: method to show the textField in the tableView cell: // Customize the appearance of table view cells - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @”Cell”; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; } // Set up the cell if (indexPath.row == 0) { UIView* cv = cell.contentView; [cv addSubview:textField]; } return cell; } EditTextController.m CH007.indd 184 9/18/10 9:48:44 AM Building the Editing Controllers ❘ 185 Implement tableView:didSelectRowAtIndexPath: to deselect the selected cell You don’t necessarily have to this to complete the functionality of your application, but the Apple Human Interface Guidelines suggest that you deselect a tableview cell after its selection Therefore, I ’m including the following code: - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { // Deselect the currently selected row according to the HIG [tableView deselectRowAtIndexPath:indexPath animated:NO]; } EditTextController.m Last, but not least, you need to implement the dealloc method to clean up any memory that your class has allocated: - (void)dealloc { [managedObject release]; [managedObjectContext release]; [keyString release]; [super dealloc]; } EditTextController.m Setting Priorities with the EditPriorityController The EditPriorityController screen, which you can see in Figure 7-8, allows the user to choose the priority for a task Again, you will implement the screen as a TableView This time, there will be a row for each priority level In the Sub Controllers group, create a new UITableviewController without a NIB called EditPriorityController In the header fi le, you will need to add instance variables and properties for a Task object and the context You will also need to add a #import directive for the Task.h header fi le Your header should look like Listing 7- LISTING 7-4: EditPriorityController.h #import #import “Task.h” FIGURE 7-8: EditPriority Controller Screen @interface EditPriorityController : UITableViewController { continues CH007.indd 185 9/18/10 9:48:44 AM ... 355 ffirs.indd i 9 /17 /10 6:52: 51 PM ffirs.indd ii 9 /17 /10 6:52:52 PM Download from Wow! eBook PROFESSIONAL Download from Wow! eBook iPhone? ? and iPad™ Database... with XML on the iPhone 2 71 CHAPTER 11 Integrating with Web Services 3 01 APPENDIX A Tools for Troubleshooting Your Applications...ffirs.indd ii 9 /17 /10 6:52:52 PM PROFESSIONAL IPHONE? ? AND IPAD™ DATABASE APPLICATION PROGRAMMING INTRODUCTION

Ngày đăng: 04/12/2022, 15:06