Objective-C ARC __weak variable reference triggers warning "__weak attribute cannot be specified on an automatic variable"
automatic-ref-counting, ios, objective-c, objective-c++, weak-references
Solution
Facing this same warning, I make it disappear using a __block attribute the following way :
__block __weak MyViewController* weakSelf = self;
Problem
I've got an app (only ios5) that inside a method declares a weak variable used inside a block to reference an instance of a view controller. ``` QRCodeViewController * __weak weakSelf = self; ``` The problem is that the compiler shows a warning saying: __weak attribute cannot be specified on an automatic variable In that application I've used a lot weak references and I never saw a warning like that, the only difference from the other classes is that this class is implemented in a .mm file since it uses a c++ object and project can't compile if I leave it as a .m. I must say that the code seems to work fine. Any suggestion?