views:

47

answers:

1

Hey guys,

So I'm running instruments on my app, and getting a leak that I could have sworn I was doing right.

+ (NSMutableArray *)decode:(NSDictionary *)encoded_faculty_array
{   
    NSArray *faculty_id_data = [encoded_faculty_array objectForKey:@"faculty_id"];
    NSArray *faculty_first_name = [encoded_faculty_array objectForKey:@"first_name"];
    NSArray *faculty_last_name = [encoded_faculty_array objectForKey:@"last_name"];

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

    for(int a = 0; a < [faculty_id_data count]; a++)
    {
        Faculty *new_fac = [[Faculty alloc] initWithFacultyId:[Dearray clean:[faculty_id_data objectAtIndex:a] withDefault:@"0"]                                
                                            andFirstName:[Dearray clean:[faculty_first_name objectAtIndex:a] withDefault:@"Name not found"] 
                                            andLastName:[Dearray clean:[faculty_last_name objectAtIndex:a] withDefault:@" "]    
                                            andBio:nil 
                                            andDegrees:nil 
                                            andTitle:nil];
        [faculty_array addObject:new_fac];
        [new_fac release];
    }

    [faculty_array autorelease];
    return faculty_array;
}

It's reporting a leak on new_fac. I released it immediately after I called it though. Any idea what could be causing that problem?

Thanks.

EDIT

Here is code for intializing the Faculty instance new_fac:

- (id) initWithFacultyId:(NSString *)new_id andFirstName:(NSString *)new_first_name andLastName:(NSString *)new_last_name andBio:(NSString *)new_bio andDegrees:(NSString *)new_degrees andTitle:(NSString *)new_title 
{ 
    if (self = [super init]) { 
        self.faculty_id = new_id; 
        self.first_name = new_first_name; 
        self.last_name = new_last_name; 
        self.bio = new_bio; 
        self.degrees = new_degrees; 
        self.title = new_title; 
    } 
    return self; 
} 
A: 

You could try checking to see if the properties of Faculty and make sure those NSStrings(firstName, lastName etc) are being released properly.

If those strings are properties that are 'retained' they should be released in Faculty dealloc.

Tom