Alex Rivera | Logout

How to initialize an empty mutable array in Objective C

Asked 2012-04-19T08:56:48.753
23

I have a list of objects (trucks) with various attributes that populate a tableview. When you tap them they go to an individual truck page. There is an add button which will add them to the favorite list in another tableview. How do I initialize an empty mutable array in Cocoa?

I have the following code:

-(IBAction)addTruckToFavorites:(id)sender:(FavoritesViewController *)controller
{
    [controller.listOfTrucks addObject: ((Truck_Tracker_AppAppDelegate *)[UIApplication sharedApplication].delegate).selectedTruck];

}
Edit
Report

1 Answer

0

listOfTrucks = [NSMutableArray array]; gives you a new mutable array.

answered 2012-04-19T08:57:39.023

Your Answer