Skip to content

Instantly share code, notes, and snippets.

@brianpartridge
Created December 27, 2010 20:16
Show Gist options
  • Save brianpartridge/756502 to your computer and use it in GitHub Desktop.
Save brianpartridge/756502 to your computer and use it in GitHub Desktop.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
// Set the font and text based on the index path
NSString *fontName = @"";
switch (indexPath.row) {
case HELVETICA:
fontName = @"Helvetica";
break;
case VERDANA:
fontName = @"Verdana";
break;
}
cell.textLabel.text = fontName;
cell.textLabel.font = [UIFont fontWithName:fontName size:cell.textLabel.font.pointSize];
// This bit just determines the user-selected font and adds the checkmark
NSString *selectedFont = [DEFAULTS stringForKey:kFont];
cell.accessoryType = UITableViewCellAccessoryNone;
if ([selectedFont compare:cell.textLabel.text] == NSOrderedSame) {
cell.accessoryType = UITableViewCellAccessoryCheckmark;
}
return cell;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment