Skip to content

Instantly share code, notes, and snippets.

@DylanVann
Last active November 8, 2015 02:47
Show Gist options
  • Select an option

  • Save DylanVann/4e863ca8310247260c19 to your computer and use it in GitHub Desktop.

Select an option

Save DylanVann/4e863ca8310247260c19 to your computer and use it in GitHub Desktop.
- (void)viewDidLaod {
//Create cells.
_tableViewData = @[
@{
@"title" : @"Section 1",
@"cells" : @[
_eventCell
]},
@{
@"title" : @"Section 2",
@"cells" : @[
_startTimeCell,
_activityCell
]},
@{
@"title" : @"Section 3",
@"cells" : @[
_deleteButtonCell
]}
];
}
#pragma mark UITableViewDataSource
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
NSDictionary *sectionDictionary = [_tableViewData objectAtIndex:(NSUInteger) indexPath.section];
NSArray *cells = [sectionDictionary objectForKey:@"cells"];
UITableViewCell *cell = [cells objectAtIndex:(NSUInteger) indexPath.row];
return cell;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return [_tableViewData count];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
NSDictionary *sectionDictionary = [_tableViewData objectAtIndex:(NSUInteger) section];
NSArray *cells = [sectionDictionary objectForKey:@"cells"];
return [cells count];
}
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
NSDictionary *sectionDictionary = [_tableViewData objectAtIndex:(NSUInteger) section];
return [sectionDictionary objectForKey:@"title"];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment