Blocks are awesome but we need to keep in mind when we access variables not declared in the scope of the block.
For example if we are using a table view and try to reload a table on completion or change its values we need to be using a local variable to do that.
__block UITableView *tbView = [self.tableView];
__block int x;
^(error, result):{
x = x + 1; // block variable
[self.tbView addSubView:exampleView] // use the block variable instead of the global variable
}
Leave a Reply