I am trying to figure out a way to use typeof
to create a weak reference to self
for use in blocks to avoid retain cycles.
When I first read about this it seems that the convention was to use __block typeof(self) bself = self;
, which compiles but using __block
to avoid retain cycles doesn't work anymore and __weak
should be used instead.
However __weak typeof(self) bself = self;
results in an error:
The type 'typeof (self)' (aka 'TUAccountsViewController *const __strong') already has retainment attributes set on it
Is there a way to use typeof
or another call to generically create a weak reference to self
?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…