ios - Passing information back from UITableViewDataSource to ViewController -
I have ViewController with a UITableView as I wanted to divide data handling, I prepared my class, Who responds to the UITWAdAdvertisers.
This class should first get data from CoreData and later from a REST API.
How did the datasource talk back to the ViewController to tell it to reload the tableView to call the data? Thought of:
- Data sources data KVO and when the array changes call
reloadData Datasource is assigned every time Datasource is assigned with a block (
[self.table reloadData] ), in the data source
- Table Make the property public ViewController therefore datasource
reloadData (which I can not really like as an idea)
- A property on datasource A representative (which I feel like a loop), which can hold visual controller to use as a table,
Is there any smart way to do this? ? Or how to solve it in a normal way? Update:
I am not interested in code.
Without more detail, it seems that you need a callback here. There are several ways that will work if you have 1 to 1 relationship (which means that your datasource needs to talk to the VC only), then this is a good case:
1.) One Representative create your own representative protocol for your data source and then the VC will follow that protocol (delegate).
2. Do this by using only one block for callback.
The KVO will work just fine, but the situation above is more according to your scenario.
You can add a table view property to your custom data source, but then why did you create that category in the first place < / Html>
- Table Make the property public ViewController therefore datasource
Comments
Post a Comment