How to correctly fill a UITableView with asynchronous content that needs to be sorted

I have a bunch of files in various sizes (>100) stored in iCloud. I have a NSMetadataQuery that returns these files. They are reported to my app from the NSMetadataQuery object in random order.

I open them and extract a couple of strings which then get sorted and displayed in a UITableView.

I have tried two approaches: A) loading each file, sorting the array of files informations, and calling reloadData on the UITableView each time. and B) waiting for all the files to have loaded and then sort the "full" array and then call reloadData once.

Option B is obviously better but basically takes just as long for the user to see results. How does one do this best?

Do I need to extract the data I display in the UITableView into a different file (i.e. PLIST), so that I can load that quicker and display it while the actual data is being loaded in the background? Or do I need to basically extend implementation A by keeping track of the Array and then calling reloadRowsAtIndexPaths: for each row that subsequently gets changed due to the sort?

What is the best practice for this scenario?



From a user point of view, faster is better, and seeing something, even incomplete, is better than seeing nothing. So:

  1. If you can maintain an index file which lists this information, use that for the display and download only what you need (like your Plist idea, but probably stored in iCloud, maybe in the key/value store)
  2. If you have to download file info, show the user an activity indicator so they know you're still working and add items to the UI as you get them (your option A)

Changing from reloadData to reloadRowsAtIndexPaths: makes for better animations, so is nice to have but not required and doesn't make things faster.

Need Your Help

Authorization is not working

php laravel authorization laravel-5.2

I'm new to Laravel. I'm developing a simple register and login form for authorizing users.

is there a way to record audio in mp4 using ruby on rails / web / html5

html5 audio mp4 recorder

I would like to find a way to record audio (not video) in mp4 format on the web.