stig/json-framework — Issue #117: SBJSON Leaks to xcode 4.2 found in Leak Intrument
Author: alx005
Created: 2011-12-28 09:47:25+00:00
State: open

Hello Am I Doing anything wrong it seems that SBJSON is leaking..

Heres How I use it

@try
{
// Store incoming data into a string
NSString *jsonString = [[NSString alloc] initWithData:receivedData encoding:NSUTF8StringEncoding];
[receivedData release];
// Create a dictionary from the JSON string
NSDictionary *results = [jsonString JSONValue];
[jsonString release];
NSDictionary *contentDictionary = [results objectForKey:@"directory"];

NSArray *mainCategory = [contentDictionary valueForKey:@"maincategoryname"];
NSArray *mainFaxNum = [contentDictionary valueForKey:@"mainfaxnumber"];
NSArray *mainNames = [contentDictionary valueForKey:@"name"];
NSArray *mainEXTN = [contentDictionary valueForKey:@"extn"];
NSArray *mainPositions = [contentDictionary valueForKey:@"position"];

NSDictionary *subCategory = [contentDictionary valueForKey:@"sub_category"];

NSArray *subCategoryNames = [subCategory valueForKey:@"subcategoryname"];
NSArray *subFaxNames = [subCategory valueForKey:@"subfaxnumber"];
NSArray *subNames = [subCategory valueForKey:@"name"];
NSArray *subExtn = [subCategory valueForKey:@"extn"];
NSArray *subPositions = [subCategory valueForKey:@"position"];

for(int ctr1 = 0; ctr1 < mainCategory.count; ctr1++)
{

NSMutableArray *tempArr = [[NSMutableArray alloc] init];

person = [[[Person alloc] init] autorelease];
person.categoryName = [mainCategory objectAtIndex:ctr1];
[tempArr addObject:person];

[categories addObject:[mainCategory objectAtIndex:ctr1]];

if(![[mainFaxNum objectAtIndex:ctr1] isEqualToString:@""])
{
person = [[[Person alloc] init] autorelease];
person.faxString = [mainFaxNum objectAtIndex:ctr1];
[tempArr addObject:person];

}

NSArray *names = [mainNames objectAtIndex:ctr1];
NSArray *extns = [mainEXTN objectAtIndex:ctr1];
NSArray *positions = [mainPositions objectAtIndex:ctr1];

for(int ctr3 = 0; ctr3 < names.count; ctr3++)
{
if(![[names objectAtIndex:ctr3] isEqualToString:@""])
{

person = [[[Person alloc] init] autorelease];
person.name = [names objectAtIndex:ctr3];
person.position = [positions objectAtIndex:ctr3];
person.extn = [extns objectAtIndex:ctr3];

[tempArr addObject:person];

}
}

if(![[subCategoryNames objectAtIndex:ctr1] isEqualToString:@""])
{
person = [[[Person alloc] init] autorelease];
person.subName = [subCategoryNames objectAtIndex:ctr1];
[tempArr addObject:person];
}

if(![[subFaxNames objectAtIndex:ctr1] isEqualToString:@""])
{
person = [[[Person alloc] init] autorelease];
person.faxString = [subFaxNames objectAtIndex:ctr1];
[tempArr addObject:person];
}

NSArray *SUBnames = [subNames objectAtIndex:ctr1];
NSArray *SUBextns = [subExtn objectAtIndex:ctr1];
NSArray *SUBpositions = [subPositions objectAtIndex:ctr1];

person = [[[Person alloc] init] autorelease];

for(int ctr4 =0; ctr4 < SUBnames.count; ctr4++)
{
if(![[SUBnames objectAtIndex:ctr4] isEqualToString:@""])
{
person = [[[Person alloc] init] autorelease];
person.name = [SUBnames objectAtIndex:ctr4];
person.position = [SUBpositions objectAtIndex:ctr4];
person.extn = [SUBextns objectAtIndex:ctr4];

[tempArr addObject:person];
}
}

// NSLog(@"Temp %@",tempArr);
[dictionary setValue:tempArr forKey:[NSString stringWithFormat:@"%@",[mainCategory objectAtIndex:ctr1]]];

[tempArr release];
}

// for(Person *aPerson in tempArr)
// {
// NSLog(@"person name_%@_ categoryName_%@_ subName_%@_ faxString_%@_ position_%@_ extn_%@_",aPerson.name, aPerson.categoryName, aPerson.subName, aPerson.faxString, aPerson.position, aPerson.extn);
// }

[mainTable reloadData];
[mainTable setHidden:NO];

[results release];
}
@catch (NSException *exception)
{
NSLog(@"err %@",exception);
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Something Went Wrong" message:@"Please Check your connection and try again." delegate:nil cancelButtonTitle:@"ok" otherButtonTitles:nil, nil];
[alert show];
[alert setTag:5];
[alert setDelegate:self];
[alert release];

}
}

Leak Tool Saved File:
http://www.mediafire.com/?uxllb2xdc5k992q