Very similar to this question, I am trying to convert a project that uses ASIHTTPRequest
& ASIFormDataRequest
to ARC.
In my view controller classes, I often refer to and use properties of the request
object in the completion blocks (looking at the response code, response data etc):
__block ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:[NSURL URLWithString:SOME_URL]];
[request setCompletionBlock:^{
if([request responseStatusCode] == 200) ....etc
When converting to ARC I get the warning:
Capturing 'request' strongly in this block is likely to lead to a retain cycle
What is the proper way to do this?
Another SO user notes in the previous thread that simply adding __weak
may cause the request to be released before the completion of the block, which I believe to be true.
How can I properly reference these properties in completion/failure blocks under ARC?