1

I see old sample code use this code a lot:

__unsafe_unretained __block AssetItem *weakSelf = (AssetItem *)self;

I remember that something has changed and this became easier. So is there now a modernized way of doing this?

openfrog
  • 40,201
  • 65
  • 225
  • 373
  • [Blocks are implemented as objects](http://clang.llvm.org/docs/Block-ABI-Apple.html#blocks-as-objects). You can use __block __weak. – Jano Sep 29 '13 at 14:16
  • mmackh is right. For Apple references, see [Avoid Strong Reference Cycles when Capturing self](https://developer.apple.com/library/ios/documentation/cocoa/conceptual/ProgrammingWithObjectiveC/WorkingwithBlocks/WorkingwithBlocks.html#//apple_ref/doc/uid/TP40011210-CH8-SW16) or "Use Lifetime Qualifiers to Avoid Strong Reference Cycles" section of the [Transitioning To ARC Release Notes](https://developer.apple.com/library/ios/releasenotes/ObjectiveC/RN-TransitioningToARC/Introduction/Introduction.html#//apple_ref/doc/uid/TP40011226-CH1-SW4). – Rob Sep 29 '13 at 14:21

1 Answers1

4
__weak typeof(self) weakSelf = self;
mmackh
  • 3,550
  • 3
  • 35
  • 51