My ViewController has a dataSource, which in my case has to fetch the data from a Webservice. Is it bad practise when I assume in my ViewController that the dataSource-methods will take quite long and only call them from another thread.
So I do the following:
- Display a list of items
- User touches a cell
- The DetailViewController is shown instantly with the parent being its
dataSource - The DetailViewController now
- Displays a loading indicator
- Asks the dataSource for the data in another Thread
- Upon completion hides the indicator (called on the main thread)
Honestly I prefer that approach to some you usually see:
UIViewControllerasks the DataSource for dataUIViewControlleris loaded with data.Although, you might give a good experience to the user, if you put an spinner on the Cell or some kind of visual reference that shows that something is happening on the background. Either way, its sometimes a matter of taste, UX, or even client requisites.
Murphy Law… So it’s a good practice to assume that and create the necessary mechanisms for when that happens.