I have a table view that's showing a list of bank transactions. When I tap one, I'd like to show the editing dialog, initialized with the current data. I'm doing something like this currently to get the controller and to initialize the text fields on its view:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
TransactionDetailViewController *transactionDetailViewController;
transactionDetailViewController = [[TransactionDetailViewController alloc] initWithNibName:@"TransactionDetailViewController" bundle:nil];
// round up data
NSMutableDictionary *rowDict = (NSMutableDictionary *)[transactions objectAtIndex:indexPath.row];
transactionDetailViewController.amountField.text = [rowDict objectForKey:@"amount"];
transactionDetailViewController.nameField.text = [rowDict objectForKey:@"name"];
transactionDetailViewController.datePicker.date = [rowDict objectForKey:@"date"];
[self.navigationController pushViewController:transactionDetailViewController animated:YES];
[transactionDetailViewController release];
}
Unfortunately, this doesn't work, because the amountField, nameField, and datePicker haven't been initialized at this point -- they're 0x00, and as a result, get passed over when I try to set their text or date values. They do get properly initialized by the time viewDidLoad gets called. Do I have to have to store the row selected in the parent controller and then call back to the File Owner from the detail view, or is there some way I can actually initialize the detail view at the same time and place I create it?