【发布时间】:2010-02-20 21:11:00
【问题描述】:
我有以下方法
-(void)request
{
responseData = [[NSMutableData data] retain];
NSString *post = [NSString stringWithFormat:@"id=%d&a_id=&d",1,1];
NSLog(@"%@",post);
NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
NSString *postLength = [NSString stringWithFormat:@"%d", [postData length]];
request = [[NSMutableURLRequest alloc] init];
[request setURL:[NSURL URLWithString:kWebURL@"/req/request.php"]];
[request setHTTPMethod:@"POST"];
[request setValue:postLength forHTTPHeaderField:@"Content-Length"];
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
[request setHTTPBody:postData];
[[NSURLConnection alloc] initWithRequest:request delegate:self];
[postLength release];
[postData release];
}
-(void)connectionDidFinishLoading:(NSURLConnection *)connection
{
[connection release];
}
我的问题是 nsmutableurlrequest 对象存在泄漏。我想我应该在某个地方发布它,但是当我尝试这样做时,我得到了一个 exec_bad_access。无论我在哪里尝试释放它,我都会在 connectionDidFinishLoading 方法的末尾收到该错误。
编辑:看起来我可以释放 NSURLConnection 对象或 NSMutableURLConnection 对象。
如果我在应该删除它们的时候尝试删除它们,我会得到一个 exec_bad_access
【问题讨论】:
标签: iphone