I have an NSMutableArray in my ApplicationDelegate and I want it to be the Data Source for my UITableViewController. My question is how to pass the object properly so as to track any changes that may happen from the AppDelegate to my TableViewController.
@interface MyTableViewController : UITableViewController {
NSMutableArray *dataSource;
// What property should add for this? (nonatomic, retain) ?
}
So how i can make this array visible to the TableViewController, without leaking memory and without creating second instance of this array?
- (id) initWithDataSource: (NSMutableArray *) source
{
dataSouce = source; ???
dataSource = [source retain];
// Should I retain? Alloc?
// How do I release it?
}
The table view controller is itself the table view’s data source. You need to implement the data source methods to return the count of the array and objects from the array.