Skip to content

Instantly share code, notes, and snippets.

@bdalziel
Last active September 15, 2016 18:39
Show Gist options
  • Save bdalziel/ad094f22bce30c9ba720a5333fca3249 to your computer and use it in GitHub Desktop.
Save bdalziel/ad094f22bce30c9ba720a5333fca3249 to your computer and use it in GitHub Desktop.
@interface ASPFantasyHomeViewController ()
@property (nonatomic, strong) ASPFantasyHomeDataWrangler *dataWrangler;
@end
@implementation ASPFantasyHomeViewController
-(void)viewDidLoad
{
[super viewDidLoad];
[ASPTableCellUtil registerLoadingLifecycleCellNibsForReuseIdentifiers:self.tableView];
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
ASPWrangledDataBlock *block = [self.dataWrangler wrangledData:indexPath.row];
UITableViewCell *cell;
switch (block.type) {
case ASPWrangledDataBlockTypeCustom: {
// Option to do custom stuff here for the "regular" content of your table
break;
}
case ASPWrangledDataBlockTypeLoading : {
ASPLoadingTableViewCell *loadingCell = [tableView dequeueReusableCellWithIdentifier:ASPTableCellUtilLoadingCellName forIndexPath:indexPath];
[loadingCell setupView:self.tableView.traitCollection];
cell = loadingCell;
break;
}
case ASPWrangledDataBlockTypeLoadError : {
NSError *error = [block.customDataHash objectForKey:@"object"];
ASPLoadErrorTableViewCell *loadErrorCell = [tableView dequeueReusableCellWithIdentifier:ASPTableCellUtilLoadErrorCellName forIndexPath:indexPath];
[loadErrorCell setupView:error retryDelegate:self traitCollection:tableView.traitCollection];
cell = loadErrorCell;
break;
}
case ASPWrangledDataBlockTypeNoData : {
ASPNoDataTableViewCell *noDataCell = [tableView dequeueReusableCellWithIdentifier:ASPTableCellUtilNoDataCellName forIndexPath:indexPath];
[noDataCell setupView:tableView.traitCollection];
cell = noDataCell;
break;
}
case ASPWrangledDataBlockTypePlaceholder : {
cell = [tableView dequeueReusableCellWithIdentifier:ASPTableCellUtilPlaceholderCellName forIndexPath:indexPath];
break;
}
}
return cell;
}
#pragma ASPLoadErrorRetryDelegate
-(void)userInitiatedRetryFollowingLoadError
{
[self.dataWrangler retryFollowingError];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment