I'm using Blocks instead of delegates for callbacks between viewControllers but i'm not able to figure out why this scenario is not working:
So I have a mainViewController which is calling a detailViewController, when returning the tableView which is a property on the mainViewController needs to be reloaded.
DetailViewController *actionDetail = [[DetailViewController alloc]initWithSaveBlock:^{
[self.tableView reloadData] //app crashes here
}];
in the detailViewController 'save' is called when the user taps the 'Save button'
- (void)save
{
if (self.saveBlock)
self.saveBlock();
[self dismissModalViewControllerAnimated:YES];
}
for some reason the [self.tableView reloadData]
does not go along with [self dismissModalViewControllerAnimated:YES]
. If I remove one of the two the app seems to work fine, obviously than I'm missing the intended behavior.
When the app crashes the message in the console is:
Previous frame inner to this frame (gdb could not unwind past this frame)
Anyone an idea why this is not working ?
Update: SaveBlock is defined like this
typedef void (^SaveBlock)();
@interface DetailViewController : UIViewController
{
}
@property(nonatomic,assign)SaveBlock saveBlock;