2010-06-22 40 views
1

我正在使用儀器來查找內存泄漏,它發現了很多! 但我不知道如何解決它。NSMutableArray循環泄漏

@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

由於wycategoriesretain屬性,你有assignement後釋放該數組。

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