From cfd473e5473cc7cf4f6336d85f81db72c9965da3 Mon Sep 17 00:00:00 2001 From: Blake Watters Date: Thu, 29 Mar 2012 14:16:58 -0400 Subject: [PATCH] Added support for configuring class -> table cell mappings using objectClassName instead of Class object --- Code/UI/RKAbstractTableController.h | 1 + Code/UI/RKAbstractTableController.m | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Code/UI/RKAbstractTableController.h b/Code/UI/RKAbstractTableController.h index d7b34d960a..8e2a597212 100755 --- a/Code/UI/RKAbstractTableController.h +++ b/Code/UI/RKAbstractTableController.h @@ -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; diff --git a/Code/UI/RKAbstractTableController.m b/Code/UI/RKAbstractTableController.m index 9c1c12ba20..646440109a 100755 --- a/Code/UI/RKAbstractTableController.m +++ b/Code/UI/RKAbstractTableController.m @@ -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]; @@ -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) {