I think I have got a little performance problem with my iPhone app.
I like to show you how I load Data from the Internet, store them on the Phone and reload them to print it out on a table view. I have several modules on the app so I hope it is ok, if I explain the general way I use to do and maybe one of you got an idea.
The amount of data is about 250 datasets with 10-20 data fields (integers / text).
Step 1: Getting a JSON data string by URL-request
I’ll start a request to an MySQL-Database by an URL-Request with some restrict values (for example city_id and last_update_time) to limit the result.
Step 2: Saving the JSON-Objects to a SQLite3 database on the iPhone.
I’ll do this because I like to use the data also in offline mode. This part should be the heavies’ one, because it takes 3/4 of the total time. I run through the objects and check if I saved this object once before. (Here I use an import_id to identify the MySQL-Database-Objects) If I did found it, I will update this dataset otherwise, I'll insert it.
Step 3: Reload the Data from the SQLite and put it into an NSMutableArray
This Array will be used by the TableView.
Note: The Data will be load in the main thread. Other threads will be used to lazy load some thumbs or showing a spinning wheel.
Is there a big mistake in the procedure? Should I load the data in another thread, but what should I display at this time in the view?
What is the best way?