Vyacheslav Vyacheslav - 1 year ago 47
Objective-C Question

EXC_BAD_ACCESS while [WKInterfaceTable setNumberOfRows:withRowType]

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];



^(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) {

So, at
[self_tableB setNumberOfRows: ndx_t withRowType:TABLEELEMENT];

I can see
. Why? What is the

Answer Source

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.