memory leak when removing objects in NSMutableArray
        Posted  
        
            by user262325
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by user262325
        
        
        
        Published on 2010-04-25T11:02:07Z
        Indexed on 
            2010/04/25
            11:03 UTC
        
        
        Read the original article
        Hit count: 233
        
iphone
Hello everyone
I hope to store MYFileObj to NSMutableArray (fileArray) and display data on an UITavleView(tableview).
//----------------------------------MYFileObj
#import <UIKit/UIKit.h>
@interface MYFileObj :  NSObject  {
    NSString *fileName;
}
-(void) setFileName:(NSString *)s ;
-(NSString *) fileName ;
@end
the array I want to store data
NSMutableArray *fileArray;
I created new object and add to fileArray
MYFileObj *newobj=[[MYFileObj alloc] init ];
NSString *ss=[[NSString alloc] initWithFormat:@"%@",path]  ;
[newobj setFileName:ss];
[ss release];
[fileArray addObject:newobj];
[newobj release];
[atableview reloadData];
After the first time relaodData and do something, I want to reload fileArray and redraw atableview.
//code to remove all object in atableview
if([fileArray count]>0)
{  
   [fileArray removeAllObjects];
   [atableview reloadData];
}  
I notice that there are memory leak. I hope to know the method "removeAllObjects" removes only MYFileObj themselves or also removes MYFileObj's member property "fileName"?
Thanks
interdev
© Stack Overflow or respective owner