2012-03-28 19 views
1

我在iOS APP中使用ASIHTTPRequest。我這樣做是這樣的: .H警告ASIHttpRequest

@interface MyClassr 
    ASIFormDataRequest *currentRequest; 
} 

NSURL *url = [NSURL URLWithString:requestUrl]; 
currentRequest = [ASIFormDataRequest requestWithURL:url]; 
[email protected]"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]; 
    } 

和我在線路warnign:[currentRequest setCompletionBlock:^ //塊將由拍攝對象物

//捕獲「自強保留的對象保留'強烈在這個區塊很可能導致一個保留週期

我該如何糾正這個警告?

回答

1

你需要創建一個弱引用自:

__weak MyClassr* blockSelf = self; 

,然後在你的塊使用該引用:

[blockSelf addAnnotation]; 
[blockSelf caculDistance];