0
-(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]);
}

I called the above code in -viewDidAppear and it's not showing any leaks when the view is appear at first time. But when i press BACK button and again click the view, then the instrument showing leaks at

  NSDictionary *makeJSON=[strValue JSONValue];

Then i added

  [makeJSON release];
  makeJSON = nil;

but i got error like

  ****-[CFDictionary release]: message sent to deallocated instance

Then i added like

  NSDictionary *makeJSON=[[strValue JSONValue]retain];

again i got error like this

  ****-[CFDictionary release]: message sent to deallocated instance

moreover,i print the **retain count of makeJSON, it shows 2

Need help!!!!! and please say where i going wrong

Jessedc
  • 12,320
  • 3
  • 50
  • 63
DineshKumar
  • 1,641
  • 15
  • 13
  • Instruments shows the object that got leaked and where it was created. This is probably not the place it is leaked. Check where this object is going, and all retain/releases on it. Running the static analyzer might give you good hints here! – Eiko Oct 04 '12 at 09:16

1 Answers1

0

did you check removing of this line

 [makeJSON release];

Bcoz you r not allocating this object or you r going to do release this object that's y it give this type of error.

Ayaz
  • 1,398
  • 15
  • 29