Question

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?

Thanks

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top