Skip to content

Instantly share code, notes, and snippets.

@keicoder
Created March 13, 2014 01:52
Show Gist options
  • Save keicoder/9520568 to your computer and use it in GitHub Desktop.
Save keicoder/9520568 to your computer and use it in GitHub Desktop.
objective-c : two ways of making UITableView Cell
//two ways of making UITableView Cell
//ex
//1. much simpler
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
// Configure the cell...
Note *note = [self.fetchedResultsController objectAtIndexPath:indexPath];
cell.textLabel.text = note.noteTitle;
return cell;
}
//2. or this way
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
}
// Configure the cell...
Note *note = [self.fetchedResultsController objectAtIndexPath:indexPath];
cell.textLabel.text = note.noteTitle;
return cell;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment