The data source for my table view is a plain NSMutableArray that will be populated as the app runs, but will be empty when the Table View first loads. The class interface looks like this...
@interface ViewController_iPhone : UITableViewController {
NSMutableArray *serverList;
}
@property (retain, readonly) NSMutableArray *serverList;
@end
My questions are...
Currently, I initialize it in the viewDidLoad method like so...
serverList = [[NSMutableArray alloc] initWithCapacity:1];
I do it this way because the array needs to be valid in order for my
numberOfRowsInSectionmethod to avoid crashing when reading thecountof the array (which will be zero) when the view first loads. My current approach of usinginitWithCapacityjust feels a little clunky since I just need an empty, but valid array object that will return a count value of zero when the view loads. How should I be initializing myserverListarray?While playing around, I noticed that when I try and initialize the
serverListarray this way...serverList = [NSMutableArray arrayWithCapacity:1];
it crashes on that line. Why?
Thanks in advance for all your help!