I wanna to update table from a background thread using this part of the code
__block typeof(self.tableB) self_tableB = self.tableB;
[lwc setBaseControllerCallback:^(int ndx) {
__block typeof(ndx) ndx_t = ndx;
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
[self_tableB setNumberOfRows: 0 withRowType:TABLEELEMENT];
[self_tableB setNumberOfRows: ndx_t withRowType:TABLEELEMENT];
}];
}];
where
^(int ndx) {
//...
}
is a block called from background thread (NSThread) and lwc - is an instance of my custom background thread class.
To clear this method is called like with: //code inside thread if (handlerBase_inner) { handlerBase_inner(ndx++); }
So, at
[self_tableB setNumberOfRows: ndx_t withRowType:TABLEELEMENT];
I can see EXC_BAD_ACCESS
. Why? What is the
I worry about self_tableB. I'm not sure that you want a strong reference to it, artificially keeping it alive might cause it to have a dangling pointer back to its delegate.
__block __weak typeof(self.tableB) self_tableB = self.tableB;
Adding a weak annotation might to the trick.