Leaks reporting issue with NSURLConnection sendSynchronousRequest
Any idea why sendSynchronousRequest
is causing a leak below? Instruments states that the responsible frame is NSURLConnection
and it points at a NSCFString
leaked in the line with sendSynchronousRequest
.
I've read that this was a known issue before OS 2.2 or something, but should definitely be fixed now. Any thoughts?
[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
NSURL *url = [NSURL URLWithString:@"http://www.mysite.com/api/v1/dosomething"];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:20.0];
[request setHTTPMethod:@"POST"];
NSData *bodyData;
[request setValue:@"text/plain" forHTTPHeaderField:@"Content-Type"];
NSString *body = @"test";
bodyData = [body dataUsingEncoding:NSUTF8StringEncoding];
[request setHTTPBody:bodyData];
[body release];
[[NSURLCache sharedURLCache] setMemoryCapacity:0];
[[NSURLCache sharedURLCache] setDiskCapacity:0];
NSHTTPURLResponse *response = nil;
NSError *error = nil;
NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&er开发者_如何学Cror];
NSString *responseString = [[NSString alloc]initWithData:responseData encoding:NSUTF8StringEncoding];
I have the same problem in my project. I write a new method, and this method makes asynchrousRequest. After that I call the method like this; performSelector.... waitUntilDone:YES . It worked for me, at least leaks are decreased.
精彩评论