-2
我對iPhone應用程序開發非常新,並且無法在我的代碼上運行泄漏分析器(XCode-> Product-> Analyze)時糾正此錯誤。它顯示了某些線路上物體的潛在泄漏。內存泄漏錯誤
1)方法返回與1的物鏡C的對象保留計數(由於參考)
2)對象上的線128分配未在此執行路徑以後引用和具有保留的1計數(對象泄露).responeData保留在財產申報部分
-(IBAction)registerButtonPressed:(id)sender
{
self.responseData = [NSMutableData data];
NSString *username = txtUsername.text;
NSString *jsonstring = [NSString stringWithFormat:@"http://demo.elgghub.com/apis/services/api/rest/json/?method=register&username=%@",username];
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:jsonstring]];
[[NSURLConnection alloc] initWithRequest:request delegate:self];
}
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response {
[responseData setLength:0];
}
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
[responseData appendData:data];
}
- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error {
[connection release];
self.responseData = nil;
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:@"Error"
message:@"Please check your network connection and relaunch the application"
delegate:self
cancelButtonTitle:@"Dismiss"
otherButtonTitles:nil, nil];
[alert show];
[alert release];
}
- (void)connectionDidFinishLoading:(NSURLConnection *)connection
{
[connection release];
NSString *responseStringReg = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
self.responseData = nil;
NSDictionary *login =(NSDictionary*)[responseStringReg JSONValue] ;
[responseStringReg release];
NSNumber *status = [login objectForKey:@"status"];
NSString *statusString = [status stringValue];
NSString *message = [login objectForKey:@"message"];
}
-(void)dealloc
{
[responseData release];
[demoView release];
[super dealloc];
}
我沒有看到任何泄漏。 – Nekto
哪一種方法和哪一行是128? – JosephH