Skip to content

Instantly share code, notes, and snippets.

@dread-pirate-bob
Created January 19, 2014 04:36
Show Gist options
  • Select an option

  • Save dread-pirate-bob/8500526 to your computer and use it in GitHub Desktop.

Select an option

Save dread-pirate-bob/8500526 to your computer and use it in GitHub Desktop.
UITableView Boilerplate
#pragma mark - TableView DataSource
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return 50.0;
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return apiCalls.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"Cell"];
}
NSDictionary *item = apiCalls[indexPath.row];
cell.textLabel.text = [item objectForKey:@"Endpoint"];
cell.detailTextLabel.text = [item objectForKey:@"Verb"];
cell.textLabel.textColor = [UIColor greenColor];
cell.detailTextLabel.textColor = [UIColor greenColor];
cell.backgroundColor= [UIColor blackColor];
return cell;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment