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

sdkIQ for iPhone
($4.99)

Your First iPhone App
($1.99)

iPhone Code Generator
($9.99)

Dual Matches
($0.99)

Calcuccino Programmers' Calculator
($2.99)

SDKtoday
(free)

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, 02:14 PM   #1 (permalink)
Almost there
 
Join Date: Dec 2008
Location: Leeds, England
Posts: 1,015
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, 03:22 PM   #2 (permalink)
Magic Hands' Daddy
 
Join Date: Aug 2008
Location: Memphis, TN, USA
Age: 22
Posts: 2,029
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.
__________________
Games
AppRoach - (v1.0)
7 Deaths In Nagamachi (v1.1)
Segment (v1.2)
ThumStruck Free (v1.5)
Plummet - new (v1.0)
ThumStruck 2! - Coming Soon

Apps
ArtsMemphis - (v1.0)
Elvis Mobile (v1.1)
DataLoss DB - (v1.1)
Lovers & Haters - (v1.0)
smithdale87 is offline   Reply With Quote
Old 02-09-2010, 03:47 PM   #3 (permalink)
Almost there
 
Join Date: Dec 2008
Location: Leeds, England
Posts: 1,015
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, 04:40 PM   #4 (permalink)
Magic Hands' Daddy
 
Join Date: Aug 2008
Location: Memphis, TN, USA
Age: 22
Posts: 2,029
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.
__________________
Games
AppRoach - (v1.0)
7 Deaths In Nagamachi (v1.1)
Segment (v1.2)
ThumStruck Free (v1.5)
Plummet - new (v1.0)
ThumStruck 2! - Coming Soon

Apps
ArtsMemphis - (v1.0)
Elvis Mobile (v1.1)
DataLoss DB - (v1.1)
Lovers & Haters - (v1.0)
smithdale87 is offline   Reply With Quote
Old 02-09-2010, 04:44 PM   #5 (permalink)
Almost there
 
Join Date: Dec 2008
Location: Leeds, England
Posts: 1,015
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
» Stats
Members: 41,860
Threads: 49,768
Posts: 213,054
Top Poster: BrianSlick (3,138)
Welcome to our newest member, gustavo7sexton
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 06:56 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0