iOS UITableView Tips(2)

#TableView Tips (2) (a chapter originally wanted to end TableView Tips, but found she was still too naive ~ too young, too simple)

Optimized architecture on ## points out some common optimization techniques in the Tips (1), but no mention on how the overall architecture, then this talk about how good the relative optimization on architecture.

ViewController almost any container treatment interface logic. But you showed the presence of a wide variety of dedicated users TableView Cell, the ViewController make very complicated, but we can reduce the coupling through a number of methods.

Model ### Cell binding and this is one of the most widely used way for people, in the Cell Model write data to a setter method, direct method of reducing the coupling dataSource in the Controller, easy separation.

@property (nonatomic, strong) xxModel *model;
- (void)setModel:(xxModel *)model大专栏  iOS UITableView Tips(2)pan>;

We handle our business logic in this top setter methods.

### Request conjunction with the Model may be established by two interface, a request is a part, the other part is the model, the request is directly converted into model portions, and write methods for the business logic layer in the request object with Controller to call.

Cell ### by the Category Category of UITableViewCell, can be reduced and the degree of coupling between the Cell model, cell and TableView achieve separation.

### Create a new DataSource by creating a file NSObject, and comply with UITableViewDataSource, so most of the time can DataSource method in the file. Stating that the custom DataSource instances you need UITableView interface.

@property (nonatomic, strong) customDataSource * dataSource;
self.tableView.dataSource = self.dataSource;

Guess you like

Origin www.cnblogs.com/lijianming180/p/12370840.html