My project displays elements in a Table View. When the user clicks a cell, the cell expands to show more info (like the App Store updates tab) and if the user taps that expanded cell, the element referred in the cell is opened in a new page (again, like the App Store). That element however has to be downloaded using an Alamofire request before it can be shown. To speed things up, I'm starting the download the element when the cell expands so when the user decides to open the element, it might already have finished downloading.
However herein lies my issue : some elements download quickly so it's very likely downloaded when the user opens the element (second tap). Some elements however are much larger and take longer to download (up to 6 seconds). How should I handle user input if the element hasn't finished downloading yet and, moreover, how should I implement it?
The easiest way was to ignore user input completely, checking if the element has downloaded with each tap to launch the segue. However it feels wrong to ignore the user and for them to have to tap more than once with the same intent. Similarly, I've used
You can use the
shouldPerformSegueWithIdentifier: function to cancel a segue.
Implement this function and use it to cancel the segue if the item hasn't downloaded yet and also set a flag that the download completion handler can check.
When the download is complete, if the flag is set the completion handler can perform the segue.
You should probably also show some sort of activity indicator so that the user knows that the data is loading