Added support for configuring class -> table cell mappings using objectClassName instead of Class object

This commit is contained in:
Blake Watters
2012-03-29 14:16:58 -04:00
parent 403522f361
commit cfd473e547
2 changed files with 5 additions and 2 deletions

View File

@@ -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;

View File

@@ -401,6 +401,10 @@ static NSString* lastUpdatedDateDictionaryKey = @"lastUpdatedDateDictionaryKey";
[_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];
@@ -418,8 +422,6 @@ static NSString* lastUpdatedDateDictionaryKey = @"lastUpdatedDateDictionaryKey";
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) {