Last active
December 24, 2015 08:19
-
-
Save jeremytregunna/6770160 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@implementation SomeVC | |
- (void)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)path | |
{ | |
... cell = ....; | |
[self configureCell:cell forIndexPath:path]; | |
return cell; | |
} | |
- (void)configureCell:(MyRatingCell*)cell forIndexPath:(NSIndexPath*)path | |
{ | |
cell.numberOfStars = [self.ratingsController starCountAtIndexPath:path]; | |
cell.body = [self.ratingsController reviewBodyAtIndexPath:path]; | |
cell.name = [self.ratingsController usernameAtIndexPath:path]; | |
cell.date = [self.ratingsController reviewedDateAtIndexPath:path]; | |
} | |
@end | |
@interface RatingsController : NSObject | |
// all the selectors we use here + an initializer that takes a piece of model data, i.e., an array | |
@end | |
@implementation RatingsController | |
- (instancetype)initWithArray:(NSArray*)array | |
{ | |
if((self = [super init])) | |
_array = [array copy]; | |
return self; | |
} | |
- (NSUInteger)starCountAtIndexPath:(NSIndexPath*)path | |
{ | |
return [[self.array[path.row] stars] unsignedIntegerValue]; | |
} | |
// ... | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment