ios - Possible to use self's ivar in block (instead of making them properties) -
this question has reply here:
assignment ivar in block via weak pointer 2 answers changing instance variable in block 1 replythis code:
__weak verycool *weakself = self; something.changehandler = ^(nsuinteger newindex) { if (newindex == 0) { [weakself.options removeobjectforkey:@"seller"]; } };
gives me warning property options not found. that's true, because options ivar, not declared property. possible somehow options weakself without declaring property?
for direct ivar access, utilize ->
. example:
__weak verycool *weakself = self; something.changehandler = ^(nsuinteger newindex) { if (newindex == 0) { verycool* strongself = weakself; if (strongself) [strongself->options removeobjectforkey:@"seller"]; } };
it's of import check strongself
non-nil
because direct access instance variable crash nil
pointer (which different invoking methods nil
receiver , property access method invocation).
ios objective-c cocoa-touch
No comments:
Post a Comment