我不明白! 仪器正显示出我泄漏这个方法泄漏在哪里?
-(void)loadData
{
if (locationData != nil) {
[locationData release];
}
self.locationData = [[NSMutableArray alloc] init];
NSData *recievedData = [NSData dataWithContentsOfURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://htmlwin001.******.net/blutalkasp/locations2.asp?uid=%@&von=%d&bis=%d", [[UIDevice currentDevice] uniqueIdentifier], von, bis]]];
NSString *recievedString = [[NSString alloc] initWithData:recievedData encoding:NSUTF8StringEncoding];
SBJsonParser *json = [[SBJsonParser alloc] init];
NSMutableDictionary *jsonData = [json objectWithString : recievedString];
NSString *tmpLocationData;
for (NSDictionary *location in [jsonData objectForKey:@"items"]) {
Location *newLocation = [[Location alloc] init];
tmpLocationData = [[NSString alloc]initWithFormat:@"%@", [location objectForKey:@"id"]];
[newLocation setLocationID:tmpLocationData];
[tmpLocationData release];
tmpLocationData = [[NSString alloc]initWithFormat:@"%@", [[location objectForKey:@"locationname"] gtm_stringByUnescapingFromHTML]];
[newLocation setLocationName:tmpLocationData];
[tmpLocationData release];
tmpLocationData = [[NSString alloc]initWithFormat:@"%@",[location objectForKey:@"locationdistance"]];
[newLocation setLocationDistance:tmpLocationData];
[tmpLocationData release];
tmpLocationData = [[NSString alloc]initWithFormat:@"%@", [[location objectForKey:@"locationaddress"] gtm_stringByUnescapingFromHTML]];
[newLocation setLocationAdress:tmpLocationData];
[tmpLocationData release];
tmpLocationData = [[NSString alloc]initWithFormat:@"%@", [[location objectForKey:@"locationdescription"] gtm_stringByUnescapingFromHTML]];
[newLocation setLocationDescription:tmpLocationData];
[tmpLocationData release];
NSNumber *tmpLocationLat = [[NSNumber alloc] initWithInteger:[[location objectForKey:@"locationlatitude"]integerValue]];
[newLocation setLocationPositionLat:tmpLocationLat];
[tmpLocationLat release];
NSNumber *tmpLocationLng = [[NSNumber alloc] initWithInteger:[[location objectForKey:@"locationlongitude"]integerValue]];
[newLocation setLocationPositionLng:tmpLocationLng];
[tmpLocationLng release];
NSString *URL;
URL = [location objectForKey:@"locationimage1"];
URL = [URL stringByReplacingOccurrencesOfString:@"[SLASH]" withString:@"/"];
NSString *tmpUrl1 = [[NSString alloc]initWithFormat:@"http://htmlwin001.******.net/blutalkasp/locationimages/data/%@", URL];
[newLocation setLocationImageURL1:tmpUrl1];
[tmpUrl1 release];
URL = [location objectForKey:@"locationimage2"];
URL = [URL stringByReplacingOccurrencesOfString:@"[SLASH]" withString:@"/"];
NSString *tmpUrl2 = [[NSString alloc]initWithFormat:@"http://htmlwin001.******.net/blutalkasp/locationimages/data/%@", URL];
[newLocation setLocationImageURL2:tmpUrl2];
[tmpUrl2 release];
URL = [location objectForKey:@"locationimage3"];
URL = [URL stringByReplacingOccurrencesOfString:@"[SLASH]" withString:@"/"];
NSString *tmpUrl3 = [[NSString alloc]initWithFormat:@"http://htmlwin001.******.net/blutalkasp/locationimages/data/%@", URL];
[newLocation setLocationImageURL3:tmpUrl3]; //Leak geschlossen
[tmpUrl3 release];
[self.locationData addObject:newLocation];
[newLocation release];
}
[recievedString release];
[json release];
}
有没有可能是[nsdictionaryobject objectForKey:@"xy"];
导致泄漏?
因为在仪器中特别是这些线条有颜色。正如你所看到的,我正在释放一切。 我对这个应用程序非常绝望。我甚至开始通过alloc/init/release来替换所有方便的构造函数(例如initWithFormat
而不是stringWithFormat
)。特别是在循环中!
但有时甚至仪器崩溃!
**谢谢我会立即尝试** – 2011-02-08 16:52:33
如果您在进行更改后遇到`EXC_BAD_ACCESS`,则为您添加了一些额外信息。 – Joe 2011-02-08 17:01:19