Skip to content

Instantly share code, notes, and snippets.

@richy486
Created July 18, 2012 02:05
Show Gist options
  • Save richy486/3133622 to your computer and use it in GitHub Desktop.
Save richy486/3133622 to your computer and use it in GitHub Desktop.
cellForRowAtIndexPath
- (UITableViewCell*) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellIdentifier = @"cellIdentifier";
// Normal cell
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil)
{
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier] autorelease];
}
// Custom Cell
MagicCell *cell = (MagicCell*)[tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil)
{
NSArray *outlets = [[NSBundle mainBundle] loadNibNamed:@"MagicCell" owner:self options:nil];
for (id currentObject in outlets)
{
if ([currentObject isKindOfClass:[MagicCell class]])
{
cell = (MagicCell*) currentObject;
[cell.accessoryView setHidden:YES];
break;
}
}
if (cell == nil)
{
return nil;
}
}
// Do something for each cell
// ...
return cell;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment