Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 02-09-2010, 03:14 PM   #1 (permalink)
Registered Member
 
Join Date: Dec 2008
Location: UK
Posts: 1,886
Default Decreasing loading time

In an app I'm working on, I'm creating custom/XML files from the users iPod (Artists, Albums, Genres, Songs, Playlists).

I'm wanting to do this on start up, so the user only has to wait once, rather than waiting each time these files are needed.

At the moment, I'm just using brute force and a "for" loop to get what I want:
Code:
NSArray * songs = [[NSArray alloc] initWithArray:[[MPMediaQuery songsQuery] collections]];
NSMutableString * fullData = [[NSMutableString alloc] init];

for (MPMediaItemCollection * item in songs){
   //Add to a NSMutableString with formatting I want
}

[songs release];

[fullData writeToFile:...];
[fullData release];
The above is run in a background thread, so that the UI doesn't hang.
On the device I'm testing with, I have just over 1000 songs, and this takes about 40 seconds to do on a iPhone 3G.

I've then got to write similar files for Artists, Albums, etc.
So in total it could take a few minutes.

I've tried running them all at the same time in different threads, and running them one after the other. There doesn't seem to be a massive difference in times.

Basically I'm wondering if there is a way I'm unaware of that would allow me to decrease the loading time, or am I already using the 'best' way?

Thanks,
Tom
harrytheshark is offline   Reply With Quote
Old 02-09-2010, 04:22 PM   #2 (permalink)
Registered Member
 
Join Date: Aug 2008
Location: Memphis, TN, USA
Age: 24
Posts: 3,547
Send a message via ICQ to smithdale87 Send a message via AIM to smithdale87 Send a message via Skype™ to smithdale87
Default

I think "lazy loading" is the best technique in general. You don't need to load those things until you absolutely have to. If possible split it up. Even though you may want the user to have instantaneous satisfaction after your app has fully loaded, waiting for minutes at a time is not good either.

I think a user is more likely to wait 5-10 secs here and there, rather than 30-40 secs all at once.
smithdale87 is offline   Reply With Quote
Old 02-09-2010, 04:47 PM   #3 (permalink)
Registered Member
 
Join Date: Dec 2008
Location: UK
Posts: 1,886
Default

Thanks for the reply.

Would you mind explaining lazy loading in a little more detail. I think I've got the basic gist that it's loading when needed, and in smaller chunks, but I'm unsure of how I can implement it for what I'm doing here, as one file can take 40 seconds on it's own.

Thanks again,
Tom
harrytheshark is offline   Reply With Quote
Old 02-09-2010, 05:40 PM   #4 (permalink)
Registered Member
 
Join Date: Aug 2008
Location: Memphis, TN, USA
Age: 24
Posts: 3,547
Send a message via ICQ to smithdale87 Send a message via AIM to smithdale87 Send a message via Skype™ to smithdale87
Default

Quote:
Originally Posted by harrytheshark View Post
Thanks for the reply.

Would you mind explaining lazy loading in a little more detail. I think I've got the basic gist that it's loading when needed, and in smaller chunks, but I'm unsure of how I can implement it for what I'm doing here, as one file can take 40 seconds on it's own.

Thanks again,
Tom
I'm not exactly what you're trying to do with these xml files, so it's hard to say for sure.
smithdale87 is offline   Reply With Quote
Old 02-09-2010, 05:44 PM   #5 (permalink)
Registered Member
 
Join Date: Dec 2008
Location: UK
Posts: 1,886
Default

They're used as a response by a webserver. Eg, a device connects to "192.168.1.2:7654", and the file is returned. Which is why I need them created when the app/webserver starts.
harrytheshark is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 988
19 members and 969 guests
Alex_TNT, AragornSG, arfius, changwei tu, eggerr, fanarin, GENnick, janice23, jjaaxx44, Marckov85, mikeirvingapps, Nicoloren, nidie, OstinGames2011, premkumarmsc1, rrlemoine, s kumar, SoulRed12, undeadlegion
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,487
Threads: 89,094
Posts: 380,134
Top Poster: BrianSlick (7,091)
Welcome to our newest member, fanarin
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 05:13 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0