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
numberOfRowsInSection
method to avoid crashing when reading thecount
of the array (which will be zero) when the view first loads. My current approach of usinginitWithCapacity
just 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 myserverList
array?While playing around, I noticed that when I try and initialize the
serverList
array this way...serverList = [NSMutableArray arrayWithCapacity:1];
it crashes on that line. Why?
Thanks in advance for all your help!