我在我的iOS APP中使用ASIHTTPRequest。我正在这样做:
。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];
}
我在行中有一个警告:
[currentRequest setCompletionBlock:^
//块将被捕获的对象强烈保留的对象保留//在此区块中强烈捕获“自我”可能会导致保留周期
请问我该如何纠正此警告?
最佳答案
您需要创建对self的弱引用:
__weak MyClassr* blockSelf = self;
然后在您的代码块中使用该引用:
[blockSelf addAnnotation];
[blockSelf caculDistance];
等等
关于objective-c - 警告ASIHttpRequest,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/9909830/