我有下面的代碼泄漏內存問題...Memorymanagement得到一個NSMutableArray的時候從NSObject類到UIViewController類
@property (nonatomic, retain) NSMutableArray *childrensArray;
-(void)connectionDidFinishLoading:(NSURLConnection *)connection {
NSLog(@"Connection finished loading.");
// Dismiss the network indicator when connection finished loading
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
// Parse the responseData of json objects retrieved from the service
SBJSON *parser = [[SBJSON alloc] init];
NSString *jsonString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
NSDictionary *jsonData = [parser objectWithString:jsonString error:nil];
childrensArray = [jsonData objectForKey:@"Children"];
// Callback to AttendanceReportViewController that the responseData finished loading
[attendanceReportViewController loadChildren];
[connection release];
[responseData release];
[jsonString release];
[parser release];
}
在的viewController下面還泄漏內存...
@property (nonatomic, retain) NSMutableArray *childrensArray;
- (void)loadChildren {
// Retrieve a array with dictionaries of children from ServiceGetChildren
self.childrensArray = [[serviceGetChildren.childrensArray copy] autorelease];
int total = [childrensArray count];
totalLabel.text = [NSString stringWithFormat:@"%d", total];
[theTableView reloadData];
}
請問您是否可以清理您的帖子的代碼。 – toto 2011-05-11 14:27:40
我只是說,但是......在你的一行泄漏之後('childrensArray = [serviceGetChildren.childrensArray copy];''你有'{'而不是}},並且我希望這不是完全的複製粘貼一次,但複製粘貼部分,對嗎?因爲如果佈局是完全一樣的,還有更多.. ahum,東西,錯誤。 – Joetjah 2011-05-11 14:28:46
@toto是的,當然對不起,現在可能更容易閱讀 – Silversnail 2011-05-11 14:52:54