Created
March 24, 2015 12:21
-
-
Save serhatsezer/1361536cd27d0449a574 to your computer and use it in GitHub Desktop.
UITableview lazy cell instatiation
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 UserDetailViewController() | |
@property(strong, nonatomic) MyCustomCell *customCell; | |
@end | |
@implementation UserDetailViewController | |
- (void)viewDidLoad { | |
[super viewDidLoad]; | |
// Load Xib file... | |
// Custom cell | |
[self.tableView registerNib:[UINib nibWithNibName:[MyCustomCell defaultIdentifier] bundle:nil] | |
forCellReuseIdentifier:[MyCustomCell defaultIdentifier]]; | |
} | |
... | |
.... | |
// Tableview delegate method | |
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { | |
if(indexPath.row == 0) { | |
return self.myCustomCell; | |
} | |
... | |
... | |
... | |
} | |
- (MyCustomCell *) customCell { | |
if(!_customCell) { | |
_customCell = [self.tableView dequeueReusableCellWithIdentifier:[MyCustomCell defaultIdentifier] | |
forIndexPath:[self customCellIndexPath]]; | |
} | |
return _customCell; | |
} | |
- (NSIndexPath *)customCellIndexPath { | |
return [NSIndexPath indexPathForRow:0 inSection:0]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment