Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Tham khảo tài liệu 'phát triển ứng dụng cho iphone và ipad - part 22', 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ả | Adding and Viewing Tasks 179 managedObjectContext properties. Last you push the new ViewTaskController onto the navigation stack and then release it. The last change in the RootViewController is to implement the TableView methods. You can leave the default numberOfSectionsInTableView tableView numberOfRowsInSection tableView commitEditingStyle forRowAtIndexPath and tableView canMoveRowAtIndexPath methods. You do need to implement the tableView cellForRowAtIndexPath to display the text property of the Task object for the row. You will also add some code to check the isOverdue transient property and display overdue tasks in red. Here is the code for tableView cellForRowAtIndexPath Available lor download on Wrnx.cnm 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 Configure the cell. Task managedTaskObject fetchedResultsController objectAtIndexPath indexPath cell.textLabel.text managedTaskObject.text Change the text color if the task is overdue if managedTaskObject.isOverdue NSNumber numberWithBool YES cell.textLabel.textColor UIColor redColor else cell.textLabel.textColor UIColor blackColor return cell RootViewController.m You should be familiar with how this code works. The beginning of the method tries to dequeue a cell and if it cannot it creates a new one. Next the code gets the Task object from the fetchedResultsController that corresponds to the requested cell. Then the cell s textLabel is set with the text from the Task object. Finally use the value of the Task s isOverdue property to determine the color of the text. Build and run the application. You should not get any errors or warnings. The application should now allow you to create new default tasks and then navigate to the .