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

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

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

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.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 08-08-2010, 04:15 PM   #1 (permalink)
Registered Member
 
Join Date: Jul 2010
Location: Montreal
Posts: 19
romy is on a distinguished road
Default plist download time..

Hello,

i hope you can help me. My application is an iphone version of an existing .NET/MSSQL website. It retrieves the data from a php page (generating a page in plist format). the plist file generated is about 200k for 200 rows. it's working great but the big problem is that it takes 10 seconds to load the data into the dictionary...and the file will get a lot larger in real app.

I previously tried with no success to:

- download and parse an XML file, which was even longer
- first download the plist file in the bundle and then get the data from the local file into the dict. too long also.
- I thought maybe the php page was taking too long to generate the plist file dynamically so I tried with a static file on the webserver, but it does not help.

- (void)applicationDidFinishLaunchingUIApplication *)application {
NSURL *url = [[NSURL alloc] initWithString:@"http://mywebsite/productsPlist.php"];
NSDictionary *tempDict = [[NSDictionary alloc] initWithContentsOfURL:url];
self.data = tempDict;
[tempDict release];
[window addSubview:[navigationController view]];
[window makeKeyAndVisible];
}


I've seen apps downloading larger data from network in less time, and I can't figure out how they do that. If you have any idea I would appreciate.

Thanks...
romy is offline   Reply With Quote
Old 08-08-2010, 07:39 PM   #2 (permalink)
Cocoa Junkie
 
Duncan C's Avatar
 
Join Date: Dec 2008
Location: Northern Virginia
Posts: 6,003
Duncan C has a spectacular aura about
Default

Quote:
Originally Posted by romy View Post
Hello,

i hope you can help me. My application is an iphone version of an existing .NET/MSSQL website. It retrieves the data from a php page (generating a page in plist format). the plist file generated is about 200k for 200 rows. it's working great but the big problem is that it takes 10 seconds to load the data into the dictionary...and the file will get a lot larger in real app.

I previously tried with no success to:

- download and parse an XML file, which was even longer
- first download the plist file in the bundle and then get the data from the local file into the dict. too long also.
- I thought maybe the php page was taking too long to generate the plist file dynamically so I tried with a static file on the webserver, but it does not help.

- (void)applicationDidFinishLaunchingUIApplication *)application {
NSURL *url = [[NSURL alloc] initWithString:@"http://mywebsite/productsPlist.php"];
NSDictionary *tempDict = [[NSDictionary alloc] initWithContentsOfURL:url];
self.data = tempDict;
[tempDict release];
[window addSubview:[navigationController view]];
[window makeKeyAndVisible];
}


I've seen apps downloading larger data from network in less time, and I can't figure out how they do that. If you have any idea I would appreciate.

Thanks...
The problem is that you are tying to read the large dataset synchronously.

Loading 200k of data takes a while. There's no avoiding it.

The code you wrote above will probably cause your app to be terminated for taking too long to launch. The system doesn't allow you to take too long to finsh handling a didFinishLaunching message. You only have a couple of seconds.

The answer is to download your data asynchronously. You want to create an NSURLRequest/NSURLConnection. It's actually pretty simple. You need to manage your NSURLConnection using a few delegate methods that give you the data as it is sent from the remote sever, and tells you when the download completes (successfully, or with an error.) If you do a google search on "NSURLConnection asynchronous download" you should find half-a-dozen sample apps that show exactly what you need to do. Here is one I found right away: Downloading an image (or anything else) asynchronously
__________________
Regards,

Duncan C
WareTo

Check out our apps in the Apple App store


Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.

See this tutorial on using UIView animations and layer animations:

See this thread on generating random, non-repeating text

Check out a very cool Macintosh Kaleidoscopes app called ScopeWorks that we released to the Mac App store.
Duncan C is offline   Reply With Quote
Old 08-08-2010, 10:33 PM   #3 (permalink)
Registered Member
 
Join Date: Jul 2010
Location: Montreal
Posts: 19
romy is on a distinguished road
Smile

Thank you Duncan !!
romy 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: 331
10 members and 321 guests
arash5500, HemiMG, iram91419, linkmx, mediaspree, Objective Zero, Paul Slocum, stanny, Touchmint, v1n2e7t
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,656
Threads: 94,116
Posts: 402,889
Top Poster: BrianSlick (7,990)
Welcome to our newest member, iram91419
Powered by vBadvanced CMPS v3.1.0

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