Skip to content

Commit

Permalink
Added support for configuring class -> table cell mappings using obje…
Browse files Browse the repository at this point in the history
…ctClassName instead of Class object
  • Loading branch information
blakewatters committed Apr 4, 2012
1 parent 403522f commit cfd473e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions Code/UI/RKAbstractTableController.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ extern NSString* const RKTableControllerDidBecomeOffline;
@property (nonatomic, retain) RKTableViewCellMappings* cellMappings;

- (void)mapObjectsWithClass:(Class)objectClass toTableCellsWithMapping:(RKTableViewCellMapping*)cellMapping;
- (void)mapObjectsWithClassName:(NSString *)objectClassName toTableCellsWithMapping:(RKTableViewCellMapping*)cellMapping;
- (id)objectForRowAtIndexPath:(NSIndexPath *)indexPath;
- (RKTableViewCellMapping*)cellMappingForObjectAtIndexPath:(NSIndexPath *)indexPath;

Expand Down
6 changes: 4 additions & 2 deletions Code/UI/RKAbstractTableController.m
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,10 @@ - (void)mapObjectsWithClass:(Class)objectClass toTableCellsWithMapping:(RKTableV
[_cellMappings setCellMapping:cellMapping forClass:objectClass];
}

- (void)mapObjectsWithClassName:(NSString *)objectClassName toTableCellsWithMapping:(RKTableViewCellMapping*)cellMapping {
[self mapObjectsWithClass:NSClassFromString(objectClassName) toTableCellsWithMapping:cellMapping];
}

- (id)objectForRowAtIndexPath:(NSIndexPath *)indexPath {
NSAssert(indexPath, @"Cannot lookup object with a nil indexPath");
RKTableSection* section = [self sectionAtIndex:indexPath.section];
Expand All @@ -418,8 +422,6 @@ - (UITableViewCell *)cellForObject:(id)object {
return indexPath ? [self cellForObjectAtIndexPath:indexPath] : nil;
}

// TODO: unit test...
// TODO: This needs to be updated to take into account header & footer rows...
- (NSIndexPath *)indexPathForObject:(id)object {
NSUInteger sectionIndex = 0;
for (RKTableSection *section in self.sections) {
Expand Down

0 comments on commit cfd473e

Please sign in to comment.