ios - How do you make a UITableViewDatasource independant of the UIViewController -


In the past, I have always entered the class and reuse ID for a cell in the view "ViewDidLoad" method of controller . It works fine when the view controller corresponds to UITableViewDataSource and acts as the data source of the table. However, I want to create an independent class that acts as a data source.

"RegisterNib: forCellReuseIdentifier:" or "registerClass: forCellReuseIdentifier:" Creating a very tight binding between calling "viewDidLoad" is a visual controller and class that is acting as a data source and The data source violates the encapsulation of the implementation: In particular, the data source should use the same class and when re-implementing "cellForRowAtIndexPath:", the ID specified in the view controller should be reused. / P>

Is there a way where the data source can specify a class and reuse the ID, and keep the internal implementation details hidden from the controller to see it?

create your data source / delegate something The way that the table configures to like.

  - Configure (Zero) tab view: (UITableView *) table view {{tableView RegisterClass: [SomeClass class] forCellReuseIdentifier: @ "Some identifier"]; }  

Alternatively, but a bit more weird (IMO), when you receive calls for cellForRowAtIndexPath (actually before dequeue), then Must have to register. You should make sure that you register only once per table view.


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -