remove rows of UITableView causes memory leak
<p>I hope to delete all rows of an UITablewView</p>

<p>The UITableView is "atableview", its data source is "fileArray".</p>

<p>NSMutableArray *fileArray;</p>

<p>fileArray is NSMutableArray for object MYFileObj</p>

<pre><code>#import &lt;UIKit/UIKit.h&gt;

NSMutableArray *fileArray;

@interface MYFileObj :  NSObject  {

NSString *fileName;

}
-(void) setFileName:(NSString *)s ;
-(NSString *) FileName ;
@end 
</code></pre>

<p>I load fileArray at first, then call [atableview reloadData];</p>

<p>after do something, I hope to reload fileArray and redraw atableview, so I call</p>

<pre><code>-(void) removeACell:(NSInteger)row;
{                                
    NSUInteger _lastSection = 0;//[self numberOfSectionsInTableView:atableview];
    NSUInteger _lastRow =row;// [atableview numberOfRowsInSection:_lastSection] - 1;
    NSUInteger _path[2] = {_lastSection, _lastRow};
    NSIndexPath *_indexPath = [[NSIndexPath alloc] initWithIndexes:_path length:2];
    NSArray *_indexPaths = [[NSArray alloc] initWithObjects:_indexPath, nil];
    [_indexPath release];



    [atableview deleteRowsAtIndexPaths:_indexPaths  withRowAnimation:    UITableViewRowAnimationNone];

    [_indexPaths release];


}


-(void) reloadList;
{


if([fileArray count]&gt;0) //----the begining of the codes cause memory leak
    {                    //I hope to remove all rows and reload fileArray
        NSInteger n=fileArray.count;
        [atableview beginUpdates];

        for(int i=n-1;i&gt;=0;i--) 
         {        
             [fileArray removeObjectAtIndex:i];
             [self removeACell:i];


         }
        [fileArray release];
        [atableview endUpdates];
    }                  //----the end of the codes cause memory leak

//load fileArray again
[atableview reloadData];

}
</code></pre>

<p>But I found this cause memory leak.</p>

<p>Welcome any comment.</p>

<p>Thanks</p>

<p>interdev</p>
