title: iOS Proper Use of @weakify(self) and @strongify(self)
body: <p>I'm starting to integrate libextobjc (<a href="https://github.com/jspahrsummers/libextobjc">https://github.com/jspahrsummers/libextobjc</a>) into my iOS application primarily to take advantage of EXTScope's <code>@strongify</code> and <code>@weakify</code>, but have a few questions before proceeding too deep into the process.</p>
  
  <p>Here's an example that's intentionally overly-complicated to try to suss out how to handle this:</p>
  
  <pre><code>- (void)someMethod {
      if (self.someBOOL) {
          _someObjectInstanceVar = [Object objectWithCompletionHandler:^{
              // self reference #1
              if (self.someProperty) {
                  // self reference #2
                  [[Async HTTPRequest] sendAWithID:self.property.id completionHandler:^(void (^)(NewObject *newObject) {
                      // self reference #3
                      [self showViewWithObject:newObject handler:^{
                          // self reference #4
                          [self reloadData];
                      }];
                  }];
              }
          }];
  
      else {
          [[Async HTTPRequest] sendBWithID:self.property.id completionHandler:^{
              // self reference #5
              [self reloadData];
          }];
      }
  }
  </code></pre>
  
  <p>My understanding is that if I want to do anything like an async HTTP request, and inside the completion handler reference self, like <code>[self reloadData]</code>, I don't need to do anything with strong/weak as the request block itself isn't retaining the completion block, so there's no problems with retain cycles there. In the above code example, I think <strong>#5</strong> is a case where a retain cycles isn't an issue.</p>
  
  <p>The main concern are all of the objects that take a block as a property/init param, that are internally holding onto the block properties. Inside the <code>objectWithCompletionHandler</code> method, where <code>someObject</code> holds onto the completionHandler block as an instance variable, there are multiple references to self there that I do know would cause a leak. My main question is in such a case, how would you need to handle <code>weakify</code> and <code>strongify</code> to make it "safer"? Would one @weakify and @strongify call each be sufficient, like the following:</p>
  
  <pre><code>- (void)someMethod {
      @weakify (self);
  
      _someObjectInstanceVar = [Object objectWithCompletionHandler:^{
          @strongify(self);
      ...
  }
  </code></pre>
  
  <p>Would the above <code>@strongify(self)</code> reference be sufficient to use for self references #1, 2, 3, and 4, or do I have to (and would it even work) get a new weak/strong reference to use inside the <code>sendAWithID</code> method and the nested <code>reloadData</code>?</p>
  
  <p>EDIT: Fixed code to have question make more sense and fix some syntax errors.</p>