Skip to content

Instantly share code, notes, and snippets.

@icodeforlove
Created July 2, 2014 20:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save icodeforlove/30838a882e0c71b9a4d5 to your computer and use it in GitHub Desktop.
Save icodeforlove/30838a882e0c71b9a4d5 to your computer and use it in GitHub Desktop.
gives CCTableView the ability to dequeueCellWithTag, this is very useful when using multiple custom CCTableViewCell's and wanting to be able to reuse them.
CCTableViewCell *CCTableView::dequeueCellWithTag(int nTag)
{
CCTableViewCell *cell = NULL;
for (int i = 0, len = m_pCellsFreed->count(); i < len; i++) {
CCTableViewCell *tempCell = (CCTableViewCell*)m_pCellsFreed->objectAtIndex(i);
if (tempCell->getTag() == nTag) {
cell = tempCell;
cell->retain();
m_pCellsFreed->removeObjectAtIndex(i);
cell->autorelease();
break;
}
}
return cell;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment