Besi Besi - 2 years ago 105
Objective-C Question

Nested blocks and references to self

I have a block wherein I use

so I declare a weak reference to self:

__weak MyClass *weakSelf = self;

Now my questions:

  1. I get an error where I define
    and I don't understand what this should mean.:

    weak attribute can not be specified on an automatic variable

  2. Inside my block I pass
    to another block and I am not sure if I now have to do the same thing again like so:

    __weak MyClass *weakWeakSelf = weakSelf;

    And then pass
    to that block?

Answer Source

This is most likely occurring as you are targeting down to iOS 4. You should change it to be

__unsafe_unretained MyClass *weakWeakSelf = weakSelf;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download