Skip to content

Instantly share code, notes, and snippets.

@dodikk
Created February 25, 2014 15:05
Show Gist options
  • Save dodikk/9210587 to your computer and use it in GitHub Desktop.
Save dodikk/9210587 to your computer and use it in GitHub Desktop.
@interface MyCell : UITableViewCell
+(NSString*)reuseId;
@property ( nonatomic, strong ) MyCellController* cellController;
@end
-(UITableViewCell*)tableView:( UITableView* )tableView
cellForRowAtIndexPath:( NSIndexPath* )indexPath
{
MyCell* cell = [ tableView dequeueReusableCellWithIdentifier: [ MyCell reuseId ] ];
if ( nil == cell )
{
// createCell
}
MyCellController* cellController = ....; // create or get one
cell.cellController = cellController; // cell retains controller
{
cellController.otherUIStuff = ....; // take it from nib or code
...
...
...
}
MyCellModel* model = ....; // controller does not retain views
[ cellController setModel: model ]; // may initiate asynchronous fetch
return cell;
}
@interface MyCellController
@property ( nonatomic, weak ) UIView* contentView;
@property ( nonatomic, weak ) UILabel* textLabel;
@property ( nonatomic, weak ) UIXyz* otherUIStuff;
// may initiate asynchronous fetch
-(void)setModel:( MyCellModel* )model;
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment