Created
February 25, 2014 15:05
-
-
Save dodikk/9210587 to your computer and use it in GitHub Desktop.
This file contains 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
@interface MyCell : UITableViewCell | |
+(NSString*)reuseId; | |
@property ( nonatomic, strong ) MyCellController* cellController; | |
@end |
This file contains 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
-(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; | |
} |
This file contains 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
@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