【发布时间】:2011-03-21 10:29:25
【问题描述】:
当我运行仪器时,我在下一行得到了内存链接
NSData *responseData = [NSURLConnection sendSynchronousRequest:theRequest
returningResponse:&urlResponse error:&error];
谁能解释一下如何解决这个问题,
谢谢 山姆。
- (NSString *)sendHttpsReq:(NSString *) urlString {
// create the request
NSString *endResult = nil;
NSURL *posHostUrl = [NSURL URLWithString:urlString];
NSURLRequest *theRequest=[NSURLRequest requestWithURL:posHostUrl
cachePolicy:NSURLCacheStorageAllowed
timeoutInterval:300.0];
// create the connection with the request
// and start loading the data
[NSURLRequest setAllowsAnyHTTPSCertificate:YES forHost:[posHostUrl host]];
NSURLConnection *theConnection=[[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
if (theConnection) {
// Create the NSMutableData that will hold
// the received data
// receivedData is declared as a method instance elsewhere
NSHTTPURLResponse* urlResponse = nil;
//NSError *error = [[NSError alloc] init];
NSError *error = nil;
NSData *responseData = [NSURLConnection sendSynchronousRequest:theRequest returningResponse:&urlResponse error:&error];
endResult = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
//[error release];
} else{
//Inform the user that the connection failed.
NSLog(@"CONNECTION FAILED");
}
[theConnection release];
return [endResult autorelease];
}
【问题讨论】:
标签: ios iphone objective-c memory-leaks