samir
samir

Reputation: 4551

Warnings ASIHttpRequest

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 ?

Upvotes: 1

Views: 87

Answers (1)

Abizern
Abizern

Reputation: 150615

You need to create a weak reference to self:

__weak MyClassr* blockSelf = self;

and then use that reference in your block:

[blockSelf addAnnotation];
[blockSelf caculDistance];

etc.

Upvotes: 1

Related Questions