0

我是Analyze用于搜索任何泄漏的应用程序,在这里我们遇到了“存储到的对象的潜在泄漏replyString”。我尝试了每个版本,但没有任何改变,所以我在这里寻求帮助。

我在我的 WebService 类中创建了这个方法。

-(NSString *)httpRequest{

NSData *postData = [self dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];

NSString *postLength = [NSString stringWithFormat:@"%d", [postData length]];

NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease];
[request setURL:[NSURL URLWithString:adresse]];
[request setHTTPMethod:@"POST"];
[request setValue:postLength forHTTPHeaderField:@"Content-Length"];
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
[request setHTTPBody:postData];

NSHTTPURLResponse *response = nil;
NSError *error = nil;
NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
NSString *replyString = [[NSString alloc] initWithBytes:[responseData bytes] length:[responseData length] encoding: NSASCIIStringEncoding];
return replyString;
}

谢谢 :)

4

1 回答 1

2

您正在创建需要释放的方法,replyString因此alloc initreplyString

return [replyString autorelease];
于 2013-09-26T10:01:30.273 回答