From a view, I push a tableView where the back button is hidden.
When one row is selected, the “back button” appear.
I would like to pass to the value of the selected row as the user tap on the back button as content of a textField.
This is the code of the tableView (CategoryListController.m):
-(NSString *)ritornaValore {
return valoreCategoria;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[self.navigationItem setHidesBackButton:NO animated:YES];
NSDictionary *rowVals = (NSDictionary *) [categoryListItems objectAtIndex:indexPath.row];
valoreCategoria = (NSString *) [rowVals objectForKey:@"key"];
[self ritornaValore];
}
valoreCategoria is a NSString declared in the .h
In AddItemController i have this “categoryNameField” where i would like to put inside the value of “valoreCategoria”
categoryNameField.text = ?
Before pushing
CategoryListControllerfromAddItemControlleryou should save reference (i.e.categoryController) to category list controller.In
viewWillAppearofAddItemControlleryou should check ifcategoryController != nil. If it is not nil, then you can try to retrieve value :categoryNameField.text = [categoryController ritornaValore];. And if you don’t need anymorecategoryControllerthen you should release itself.categoryController = nil;.Check that
categoryControlleris defined as@property (nonatomic, retain) CategoryListController *categoryController;andvaloreCategoriaas@property (nonatomic, retain) NSString *valoreCategoria;.