Note that there are some explanatory texts on larger screens.

plurals
  1. POPattern for preloading data for subsequent view to be displayed
    primarykey
    data
    text
    <p>Very simple use case: Let's say an iOS app displays a <code>MovieListController</code> view (inside of a <code>UINavigationController</code>) with a list of movies. When the user touches on one, the app pushes a <code>MovieDetailController</code> onto the navigation stack (i.e. <code>[[MovieDetailController alloc] initWithMovieId:(NSString *)</code>. In the <code>MovieDetailController</code>'s <code>viewDidAppear:</code> method, it makes an HTTP call to retrieve details based on the movie ID passed into it. </p> <p>The challenge is that the <code>MovieDetailController</code> gets pushed onto the navigation stack right away, and for a second or two while the details haven't been retrieved, the view shows a bunch of blank fields, which is undesirable.</p> <p>To get around this, I'm thinking of having the <code>MovieListController</code> not push the <code>MovieDetailController</code> onto the stack right away. Instead, it would put up a progress indicator (I'm using SVProgressHUD), then call <code>MovieDetailController</code>'s <code>initWithMovieId:</code> method which would kick off the HTTP call. Then when the data is received, the <code>MovieDetailController</code> would make a callback back to <code>MovieListController</code> to remove the progress indicator and then push the <code>MovieDetailController</code> onto the navigation stack. </p> <p>Is there a better pattern for this type of scenario? Should I be considering having the <code>MovieDetailController</code> push itself onto the navigation stack when it's ready? </p> <p>Note: I have considered loading the detail view and putting up an activity indicator, but you'll still be able to see an 'empty view' behind it which looks a bit weird. I have also considered just having the <code>MovieListController</code> retrieve the details itself but this seems to break the encapsulation model - the <code>MovieListController</code> should just be concerned about listing movies, not about their details.</p> <p>Any thoughts? This Movie stuff is just an example - looking for a general pattern here.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload