Created
February 5, 2012 19:59
-
-
Save asmallteapot/1747711 to your computer and use it in GitHub Desktop.
Less-hacky approach for configuring table views that are mostly static, but have some sections/cells that are conditionally visible.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // in -viewDidLoad | |
| self.cellOrder = [NSMutableArray arrayWithObjects:@"Address", @"Hours", @"Call", @"Get Directions", nil]; | |
| if (foo) { | |
| [self.cellOrder removeObject:@"Hours"]; | |
| } | |
| if (!self.location.phoneNumber) { | |
| [self.cellOrder removeObject:@"Call"]; | |
| } | |
| // in data source & delegate methods | |
| NSString *cellName = [self.cellOrder objectAtIndex:indexPath.row]; | |
| if ([cellName isEqualToString:@"Hours"]) { | |
| // do something | |
| } else if ([cellName isEqualToString:@"Call"]) { | |
| // do something else | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment