1

I'm reading many plists and displaying them in a UITableview. The problem is, the app itself is very slow and I did read something about archiving or serialization, does archiving will make the app faster or I shall try to use sqlite if I want to use a huge amount of data?

It would be nice if someone could help me telling me how to archive my data or how to serialize that to optimise the plists.

This is what i have: (where i'm collecting all the arrays in 'data")

- (void) makeData {
    data = [[NSMutableArray alloc] init];
    sectionArray = [[NSMutableArray alloc] init];

    //here we connect each array built with the remote plist on the server - different plists for each
    amenajariArray = [[NSMutableArray alloc] initWithContentsOfURL:[NSURL URLWithString:@"http://..../amenajari.plist"]];
    apicultoriArray = [[NSMutableArray alloc] initWithContentsOfURL:[NSURL URLWithString:@"http://..../apicultori.plist"]];
    asigurariArray = [[NSMutableArray alloc] initWithContentsOfURL:[NSURL URLWithString:@"http://..../asigurari.plist"]];
bryanmac
  • 38,941
  • 11
  • 91
  • 99

2 Answers2

1

You're making what looks to be three synchronous web requests to get the data. You should make those async and parallel at a minimum. You can also take the approach of synchronizing or updating data in the background and shipping out of the box with a default set of data. Look at dispatch_async blocks or operation queues in the concurrency programming guide. You can also look into the async methods in ASIHttpRequest. You have to find a way to not block the UI thread for consecutive blocking http requests. Another SO posts on GCD async UI: performSelectorOnMainThread with multiple parameter

Also, If you're persisting many lists of data and you're starting to hit perf problems, you might want to look into sqlite or core data (backed by sqlite).

Remember that if you're persisting lists, modifying one item/property will write the whole list. Also, if you're storing many lists (especially if there's relationships between the data), a database might be more appropriate. It can also offer faster and more optimized querying patterns.

Community
  • 1
  • 1
bryanmac
  • 38,941
  • 11
  • 91
  • 99
  • Isn't there any chance to use the plists , i'm loading like 15 different plists , basically for each category that im using. – Bogdan Christian May 27 '12 at 15:47
  • Sure, you can use plists - I was just pointing out that depending on your perf problems and the complexity of your data, a database *might* be a better option. Just wanted to provide some other options to explore ... – bryanmac May 27 '12 at 15:52
  • thank you so much for your cooperation and answers, because i spent some time i will try now to see if there is a solution to optimise this plists, which basically contain like 4-5 informations each , nothing so big. If there isn't any solution for this i think i should look then for sqlite – Bogdan Christian May 27 '12 at 15:56
  • You're making what looks to be three synchronous web requests to get the data. You should make those async and parallel at a minimum. You can also take the approach of synchronizing or updating data in the background and shipping out of the box with a default set of data. >> Can you provide a little bit more details here, i'm new on this.... – Bogdan Christian May 27 '12 at 15:58
  • I added some links to different resources. Basically, UI updates happen on a UI main thread run loop. If you call that method from the main thread, everything will block until that method returns. In that method, each of the http calls are synchronous which means the next one doesn't start until the previous one returns. Async allows you to start off the http request, continue and provide a call back function that says, hey when that long network call returns, call this function. A good rule of thumb is to not cross a network on the UI thread. – bryanmac May 27 '12 at 16:02
0

In above situation your array is already serialize in plist (xml) format. Even if you serialized into binary format, it will not increase the performance as you like.

To increase the performance, you can use the lazy loading concept to filling the array of table view datasource. Or show the first 25 rows then show the button for next 25. Theses things required a sqlite or core data.

Atif
  • 1,220
  • 11
  • 16