memory leak when removing objects in NSMutableArray
- by user262325
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