I have a UITableView called UserProductViewController and this table view used for two purpose "create and edit" some data. When user click "edit button" open this UserProductViewController edit mode and populate some data within cell from another method. I don't want to store all server-side values in property instead I was use Lazy instantiation cell. This approach sometimes makes trouble. To be clear here is my code this approach correct or not ? Could you please guide me correct way to do this?
Implementation Interface
@interface UserProductViewController()
@property(strong, nonatomic) MyCustomTableViewCell *myCustomCell;
@end
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
...
if(indexPath.row == 2) return self.myCustomCell;
...
}
- (MyCustomTableViewCell *)myCustomCell {
if(!_myCustomCell) {
_myCustomCell = [self.tabView dequeueReusableCellWithIdentifier:@"CustomIdentifier" forIndexPath:[self customIndexPath]];
}
return _myCustomCell;
}
- (NSIndexPath *)customIndexPath {
// 2 correspond to cellForRowAtIndexPath indexPath value.
return [NSIndexPath indexPathForRow:2 inSection:0];
}
Server side method I'm using that cell as a property like this:
- (void) getUserValues {
....
// getting server-side result
// completion block
self.myCustomCell.titleLabel = result.title;
}
Other question is what would happen if I don't want to use tableview dequeue system ?