I have a numberOfSections... method that looks like this:
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
BOOL showContacts = self.selectedReminderMessageService != RMReminderMessageServiceTwitter ? YES : NO;
if (self.isEditing) {
if (showContacts) {
return 5;
} else {
return 4;
}
} else {
if (showContacts) {
return 4;
} else {
return 3;
}
}
}
How should I create the cellForRowAtIndexPath... method? Do I have to list all possible configurations like so:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
BOOL showContacts = self.selectedReminderMessageService != RMReminderMessageServiceTwitter ? YES : NO;
NSInteger section = [indexPath section];
if (self.isEditing) {
if (showContacts) {
if (section == 0) {
// repeat to section 4 with else if's
}
} else {
if (section == 0) {
// repeat to section 3 else if's
}
}
} else {
if (showContacts) {
if (section == 0) {
// repeat to section 3 else if's
}
} else {
if (section == 0) {
// repeat to section 2 else if's
}
}
}
}
Can this be made in a more efficient way?