Populate a UITableView with data


Populate a UITableView with data



First of all, while I have an understanding of some of the basics, I'm am still somewhat of a newbie.

I have a sectioned UITableView that I am currently using NSDictionary(for grouping) and 4 or 5 different NSArrays (for data, some of which gets passed to the next view when a cell is selected) to populate the table. It works but it's a very long list and after a few minutes of scrolling the UITableView up and down, leaving that view and coming back to it, the app starts to "slow down" and eventually freezes. I have been doing some research and have found that the way I am doing that is not the best way. I have read about using another object to populate the table which will only load data as needed and won't keep that data in memory(which is probably causing my app to freeze).

Can anyone help point me in the right direction to build a "data object" to store my data and then use it in my UITableVIew? Can I just take my NSDictionaries and NSArrays and somehow put them in thier own class and call that class? Would I use Core Data? Any other suggestions? As a note, this data cannot be added to, updated, or deleted by the user. The only time I will change the data is to add more data(a completely new record) to make the list longer and maybe once in a while, but very rarely, updated or deleted by me.

Any help would be greatly appreciated.




What's this {{0,0},{w,h}} doing?

1:



Getting phone UUID through iPhone SDK


2:


It is true that UITableViewController is most efficient when coupled with CoreData.

To do this, you should look into NSFetchedResultsController.

If you want an easy way to get into CoreData, use MagicalRecord.

It is very easy to use and very efficient.. However, it is worth noting that an NSDictionary with several NSArrays filled with thousands of NSStrings should not cause you memory problems.

The fact that you are able to load this into memory in the first place suggests that you can hold the entire data structure in memory.

The fact that you slow down and freeze when scrolling means that the memory problem comes from UITableView cell instantiation.

. Here are a few things you should check:.
  1. Do you know how to use Instruments? If so, check for memory leaks.

  2. Do you receive didReceiveMemoryWarning in your UITableViewController? I'm guessing so.

    But you want to be sure it's not some thread blocking issue.

  3. Are you using images in your UITableViewCells? If you have thousands of images, you definitely want to use an NSCache to store it.

    That will automatically clear up memory when needed.

  4. Are you using custom UITableViewCells? Since you are experiencing slowdown from scrolling, check that the custom cell isn't having problems drawing.

  5. Make sure you are dequeueing cells.

    This is done in template UITableViewController code, but you may have removed it for some reason.




78 out of 100 based on 23 user ratings 848 reviews