Right now I have a portion of code like this:
__strong MyRequest *this = self;
MyHTTPRequestOperation *operation = [[MyHTTPRequestOperation alloc]initWithRequest:urlRequest];
[operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *request, id responseObject) {
[this requestFinished:request];
}
failure:^(AFHTTPRequestOperation *request, NSError *error) {
[this requestFailed:request withError:error];
}];
I am mainly doing this because some other classes are inheriting from the class where this code is located and implementing their own requestFinished and requestFailed.
If I change the self reference to __weak I start getting some EXC_BAD_ACCESS errors. With a __strong reference everything works fine but I'm afraid about creating a retain cycle. Note that i am using ARC.
Is this code creating a retain cycle that will cause problems? Any simple solution to this? Any different approach that I can follow to let inheriting classes implement their own methods to handle responses?