Skip to content

Commit

Permalink
[models] Add support for generating unique cell.object identifiers to…
Browse files Browse the repository at this point in the history
… NICellFactory.
  • Loading branch information
jverkoey committed Apr 8, 2013
1 parent 5a942c1 commit ba47c24
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/models/src/NICellFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,15 @@ _model.delegate = (id)[NICellFactory class];

@optional

/**
* Asks the receiver whether the mapped object class should be appended to the reuse identifier
* in order to create a unique cell.object identifier key.
*
* This is useful when you have a cell that is intended to be used by a variety of different
* objects.
*/
+ (BOOL)shouldAppendObjectClassToReuseIdentifier;

/**
* Asks the receiver to calculate its height.
*
Expand Down
5 changes: 5 additions & 0 deletions src/models/src/NICellFactory.m
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ + (UITableViewCell *)cellWithClass:(Class)cellClass

NSString* identifier = NSStringFromClass(cellClass);

if ([cellClass respondsToSelector:@selector(shouldAppendObjectClassToReuseIdentifier)]
&& [cellClass shouldAppendObjectClassToReuseIdentifier]) {
identifier = [identifier stringByAppendingFormat:@".%@", NSStringFromClass([object class])];
}

cell = [tableView dequeueReusableCellWithIdentifier:identifier];

if (nil == cell) {
Expand Down

0 comments on commit ba47c24

Please sign in to comment.