views:

204

answers:

2

Hey.

I have seen many apps that load data to UITableViews from the internet, and they usually load smoothly. Now it's my turn to load in that kind of data. I am getting different data at the same time, separating categories with ~ and pieces of categories with #. This works great, and I have managed to separate the data in obj-c perfectly.

Everything in my app works, it's just that the loading takes a lot of time.

So, I guess the real question is, how can you load in data for a tableView in the background, showing a label/UIActivityView or something while it is loading?

Thank you.

A: 

I am not getting your question clearly. Why don't you use UIActivityIndicator to show the loading. You can do it from your nib or programmatically. One ting is also possible that you can load the contents From intenet by using NSXMlParsing which will be much quiker and show an activity indiacator until all date gets parsed and filling the table entirely at once.

Do reply if you get this.

A: 

The simplest way is to add a temporary cell which shows some kind of loading progress (label with 'Loading...' text, or a UIActivityIndicator, etc). When your data is done loading, remove that cell and add your actual cells with your data.

To load data 'in the background' I would recommend having a look at NSURLConnection. It lets you implicitly load the data asynchronously so you don't have to deal with threads.

Nebs
I have a lot of manipulating to do with the string after I get it, so I found it best to put that in a selector and do `[self performSelectorInBackground:selector]`. So, what I want to know, really, is how I can get informed when every process from a selector is done.
Emil
In your selector method you can call performSelectorOnMainThread:withObject:waitUntilDone: when the process is done which will call another selector method in the main thread. So basically you manually call the main thread when your child thread is done working to notify it.
Nebs
I really wish I could give all my points to Nebs! Your comment helped me solve an issue I head.Thanks A LOT!
changelog