I guess it really depends:
(I'm assuming you have 'anotherArray' declared in your .h file and properties set and that this array was created in a view controller and not the delegate):
You can put this piece of code in your view controller
- (void)viewWillAppear:(BOOL)animated
{
NSMutableArray *tempArray = [[NSMutableArray alloc] init];
self.anotherArray = tempArray;
[tempArray release];
}
or in your appDelegate:
create a instance of class that holds this array in the appDelegate.h:
YourViewController *viewController;
with properties/synthesize, (obviously you also have to import your YourViewController.h and declare class), and then in your appDelegate.m it would be:
- (void)applicationDidFinishLaunching:(UIApplication *)application
{
NSMutableArray *tempArray = [[NSMutableArray alloc] init];
viewController.anotherArray = tempArray;
[tempArray release];
}
One creates and allocates memory for it every time view appears while the other only creates and allocates memory for it once.
Either way will work tho...
Once you put the three lines of code in one of those methods you can then remove
anotherArray = [[NSMutableArray alloc] init];
from the addRowBtton method.