i am using ASIHTTPRequest in my iOS APP. i am doing like this :
.h
@interface MyClassr
ASIFormDataRequest *currentRequest;
}
NSURL *url = [NSURL URLWithString:requestUrl];
currentRequest = [ASIFormDataRequest requestWithURL:url];
currentRequest.requestMethod=@"GET";
currentRequest.delegate =self;
[currentRequest setCompletionBlock:^{
listesRestaurants = [XMLParser parseRestaurantResponse:[currentRequest responseData]];
NSLog(@"%@",[currentRequest responseString]);
if (apDelegate.modeGeoloc) {
[map removeAnnotations:map.annotations];
[self addAnnotation];
[self calculDistance];
}
and i have a warnign in the line: [currentRequest setCompletionBlock:^ // Block will be retained by an object strongly retained by the captured object
// Capturing ‘self’ strongly in this block is likely to lead to a retain cycle
How i can correct this warnind please ?
You need to create a weak reference to self:
and then use that reference in your block:
etc.