views:

29

answers:

1

Hi, I´m using instruments to find memory leaks, and it found a lots! But i don´t know how to fix it.

@property(nonatomic, retain) NSMutableArray *wycategories;
...
...
self.wycategories = [[NSMutableArray alloc]init];
...
...
for (CXMLElement *node in nodes) {      
    //Instruments say that here there are a lots of memory leaks
    WaiYahCategory *wycategory = [[WaiYahCategory alloc] init];

    wycategory.text = [[node childAtIndex:0] stringValue];
    wycategory.idCategory = [[node attributeForName:@"id"] stringValue];
    wycategory.desc = [[node attributeForName:@"desc"] stringValue];
    wycategory.icon = [[node attributeForName:@"icon"] stringValue];

    [self.wycategories addObject:wycategory];
    [wycategory release];
}
+1  A: 

As the wycategories has a retain attribute, you have to release the array after the assignement.

NSMutableArray *array = [[NSMutableArray alloc]init];
self.wycategories = array; // <- The property retains the array
[array release];
Laurent Etiemble