-(void)loadMakes:(NSString *)strValue
{
NSDictionary *makeJSON = [strValue JSONValue];
NSDictionary *makes = NULL;
NSDictionary *car = NULL;
NSArray *keys = NULL;
NSMutableArray *tempCar = [[NSMutableArray alloc]init];
if ([makeJSON count] != 0)
{
makes = [makeJSON objectForKey:@"makes"];
keys=[[makes allKeys]sortedArrayUsingSelector:@selector(localizedCaseInsensitiveCompare:)];
for(int i=0; i<[makes count]; i++)
{
car = [makes objectForKey:[keys objectAtIndex:i]];
CarMake *carMakeObj = [[CarMake alloc]init];
[carMakeObj setCarName:[car objectForKey:@"name"]];
[carMakeObj setCarLinks:[car objectForKey:@"link"]];
//[carMakeObj Print];
[tempCar addObject:carMakeObj];
[carMakeObj release];
}
self.carNamesArrayList=tempCar;
[tempCar release];
}
NSLog(@"count %d",[carNamesArrayList count]);
}
我在 -viewDidAppear 中调用了上面的代码,当视图第一次出现时它没有显示任何泄漏。但是当我按下 BACK 按钮并再次单击视图时,仪器显示泄漏
NSDictionary *makeJSON=[strValue JSONValue];
然后我加了
[makeJSON release];
makeJSON = nil;
但我遇到了错误
****-[CFDictionary release]: message sent to deallocated instance
然后我添加了喜欢
NSDictionary *makeJSON=[[strValue JSONValue]retain];
我又遇到了这样的错误
****-[CFDictionary release]: message sent to deallocated instance
此外,我打印了makeJSON 的 **retain 计数,它显示 2
需要帮忙!!!!!请说出我哪里出错了