Note that there are some explanatory texts on larger screens.

plurals
  1. POASIHTTPRequest completionBlock + ARC
    primarykey
    data
    text
    <p>I have the following code to download an image:</p> <pre><code> imageRequest = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:magazineItem.contentURL]]; __weak ASIHTTPRequest *weakRequest = imageRequest; __block typeof (self) bself = self; [imageRequest setCompletionBlock:^{ if (weakRequest.responseStatusCode == 200) { bself.imageData = weakRequest.responseData; [[DataAccessLayer sharedInstance] storeTemporaryContentData:bself.imageData url:magazineItem.contentURL]; bself.contentImage = [UIImage imageWithData:bself.imageData]; if (bself.contentImage != nil) { if (bself.magazineItem.presentationStyle.intValue != -1) { [bself setPresentationStyle:bself.magazineItem.presentationStyle.intValue]; } else { [bself setPresentationStyleForImage:bself.contentImage]; } } else [bself.delegate contentItemViewUnavailable:bself]; } else { [bself.delegate contentItemViewUnavailable:bself]; } }]; [imageRequest setFailedBlock:^{ if (weakRequest.error.code == 4) return; [bself.delegate contentItemViewUnavailable:bself]; }]; [imageRequest startAsynchronous]; </code></pre> <p>And though I'm using a <code>__block typeof (self)</code> identifier to pass the self into the block, it still gets retained. I also have tried <code>__weak MyClassName *bself = self;</code> and it still gets into retain cycle. It seem I'm missing something here, can anyone fill me up with what exactly am I doing wrong?</p> <p>For reference <code>imageRequest</code> is a __strong iVar in my .m file category.</p> <p>Thanks in advance.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload