When setting up a UITableView's data source, I'd be interested to get views on which is better, solution A:
NSString *labelText;
switch (indexPath.row) {
case 0:
labelText = @"Setup New Match";
break;
case 1:
labelText = @"Teams";
break;
case 2:
labelText = @"Players";
break;
case 3:
labelText = @"Archive";
break;
}
cell.textLabel.text = labelText;
or solution B?
NSArray *labels = [NSArray arrayWithObjects:@"String 1", @"String 2", @"String 3", @"String 4", nil];
cell.textLabel.text = [labels objectAtIndex:indexPath.row];
The DRY fan in me tends towards solution B, but then I'm creating an array on every loop just for the purpose of extracting one object. Is there any particular reason for using either solution over the other or is it just a personal preference?