title: Block leak with __block variable
body: <p>I have a big memory leak that I have pinpointed to happen in/on <code>requestContentEditingInputWithOptions:</code> method. If I understand it right it happens with the <code>img</code> variable. If I make it <code>__block __weak</code> the image is nil already after I assign it <code>(img = [UIImage...])</code>. Am I being silly somewhere? Or how would I avoid this memory leak? </p>
  
  <pre><code>- (UIImage*) getRightlySizedImgFromAsset:(PHAsset*)asset {
  
      __block UIImage *img;
  
  
      PHContentEditingInputRequestOptions *coptions = [PHContentEditingInputRequestOptions new];
      coptions.canHandleAdjustmentData = ^BOOL(PHAdjustmentData *adjustmentData) { return NO; };
  
      //semaphore used so the block runs synchronously and I can return img from this method at the end
      dispatch_semaphore_t sem = dispatch_semaphore_create(0);
  
      [asset requestContentEditingInputWithOptions:coptions completionHandler:^(PHContentEditingInput *contentEditingInput, NSDictionary *info) {
          NSURL* url = [contentEditingInput fullSizeImageURL];
          int orientation = [contentEditingInput fullSizeImageOrientation];
  
          CIImage* inputImage = [CIImage imageWithContentsOfURL:url options:nil];
          inputImage = [inputImage imageByApplyingOrientation:orientation];
          CIContext *context = [CIContext contextWithOptions:nil];
  
          img = [UIImage imageWithCGImage:[context createCGImage:inputImage fromRect:inputImage.extent]];
  
          dispatch_semaphore_signal(sem);
      }];
      dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER);
  
  
      if (needToDoSomethingWithImg){
          [self doSomethingWithImage:img];
      }
  
  
      return img;
  }
  </code></pre>