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:&error];
NSString *responseString = [[NSString alloc]initWithData:responseData encoding:NSUTF8StringEncoding];