Yolo
Yolo

Reputation: 1579

When or in which controller should i load external data?

Say i have two controllers and probably a stupid question.

  1. UITableView -> loads cell items from external HTTP resource
  2. UIViewController -> loads information from external HTTP resource based on the cell that was tabbed

Should i/ Does one load the data needed in 2. within the table view class 1. and send it to the view controller, or load it in the view controller class 2. that gets shown when cell has been tabbed?

NB: When a cell item is tabbed, i will be using ActivityIndicator to show a loading screen.

Upvotes: 0

Views: 13

Answers (1)

Michael Dautermann
Michael Dautermann

Reputation: 89559

Your question isn't super clear.

A view controller contains a view (and subviews, like your UITableView), so many developers typically use their subclassed UIViewController as a UITableViewDataSource for a table view that it's displaying.

If you have a more complicated architecture, perhaps you can designate another object to be your table view's data source.

If you select (or tab) on a different cell in the table, you can use UITableViewDelegate methods to detect another cell was selected and then adjust the data source and reload the data.

Upvotes: 1

Related Questions