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

View Single Post
Old 02-09-2010, 03:14 PM   #1 (permalink)
harrytheshark
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
 

» Advertisements
» Stats
Members: 158,864
Threads: 89,223
Posts: 380,688
Top Poster: BrianSlick (7,129)
Welcome to our newest member, elliotbrady
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 05:50 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.