Another way of reloading tableview data without blocks


just wanted to throw this out there, I understand that the book is trying to show how to use blocks in order to reload the tableview data after a save: but I thought I would share another way of dealing with it w/o the use of blocks. Just for curiosity’s sake :

In BNRDetailViewController : I use the presentingViewController property and cast it to a UINavigationController* since the save: action gets called from there, then get the topViewController from the navigation controller, which is the UITableView and cast that so the compiler doesn’t freak out, then just use that to reloadData:

-(void) save:(id)sender
    [self.presentingViewController dismissViewControllerAnimated:YES completion:nil];
    UINavigationController *navController = (UINavigationController*) self.presentingViewController;
    UITableViewController *tableViewController = (UITableViewController*) navController.topViewController;
    [tableViewController.tableView reloadData];

I tested it very quickly and it worked but didn’t do any profiling, so I’m guessing this is ok to do.
Can’t think of a reason why this would cause a memory leak or other side effect, but would welcome any thoughts / comments.


Only problem doing this in comparison to block is that the name of the item after tapping the save button are the default name generated on item creating. The name remains the same until another item is added but now the new item has a default name and the loop continues.