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 05-15-2009, 10:19 AM   #1 (permalink)
[self setSkills: ∞];
 
Join Date: Dec 2008
Age: 28
Posts: 111
Default Retrieving a set of data from my own webserver

I plan to have a MySQL database on my server, from which I would query and retrieve several different types of data. Namely, I'd be retrieving data from CHAR (text), date, and BLOB (image) columns. This data would not be very large; images would be low- to mid-quality and quite small, maybe a few KB each. I'd like to send a POST request to my server with query parameters in it (and login credentials), and receive the result set of that query, in a format suitable for manipulating in XCode and displaying it on the user's screen.

I already have an app on the store that uploads data to a PHP form on my server, which then talks to a MySQL database, so that part of things isn't a problem. However, I don't have any experience with retrieving complex result sets and parsing them for use in an app.

What would be the most effective, and least memory-intensive, way to do this? I'd like things to load as quickly as possible; I'd be limiting the size of my result sets as well (i.e. only 20 records at a time) so there wouldn't be a large amount of data to retrieve in any one request. Initially I feel like I should look into sending the data from the PHP form to the phone in an XML format and then parsing it, but I'm not very familiar with XML and have read that it can be more expensive than other solutions memory-wise.

If you want an idea of what I'm trying to achieve, iTunes or the App Store is a perfect example.

1) The user makes a selection (i.e. the "Games" category on the App Store)
2) The phone retrieves data from a server and spends a few seconds loading it
3) The "result set" is shown: 25 rows, each one with a small image (the app's icon), some text (the app's name), and maybe some supporting information like the app's developer and the rating
4) The user taps "more" if they want further results, and the phone retrieves the next 25


Thanks!
__________________
Want a free copy of my MMS app? http://www.iphonedevsdk.com/forum/pr...plication.html
cjpearl is offline   Reply With Quote
Old 05-15-2009, 10:24 AM   #2 (permalink)
New Member
 
Join Date: Jan 2009
Posts: 36
Default

I'm doing similar stuff to what you mention, using an HTTP GET (rather than a POST) and handling XML content coming back. I think XML is pretty much the standard for what you want to do, and there is good support for XML parsing in the iPhone SDK (using NSXmlParser). There is no issue with memory size or execution. There is a bit of a learning curve if you have no familiarity with XML, but IMO its worth climbing it because XML is ubiquitous as far as interacting with servers of any kind these days.
__________________
My Apps - Carbfinder, My BG Lite
beachdog is offline   Reply With Quote
Old 05-15-2009, 02:55 PM   #3 (permalink)
[self setSkills: ∞];
 
Join Date: Dec 2008
Age: 28
Posts: 111
Default

Thanks!
__________________
Want a free copy of my MMS app? http://www.iphonedevsdk.com/forum/pr...plication.html
cjpearl is offline   Reply With Quote
Old 05-19-2009, 01:11 AM   #4 (permalink)
[self setSkills: ∞];
 
Join Date: Dec 2008
Age: 28
Posts: 111
Default

A question. What would be the best way to incorporate images? It doesn't look like I can easily do that in XML, unless maybe I encode it (i.e. base-64) server-side, send it as XML, and then decode it on the device?
__________________
Want a free copy of my MMS app? http://www.iphonedevsdk.com/forum/pr...plication.html
cjpearl is offline   Reply With Quote
Old 05-19-2009, 03:44 PM   #5 (permalink)
New Member
 
Join Date: Jan 2009
Posts: 36
Default

Quote:
Originally Posted by cjpearl View Post
A question. What would be the best way to incorporate images? It doesn't look like I can easily do that in XML, unless maybe I encode it (i.e. base-64) server-side, send it as XML, and then decode it on the device?
I would think you could do it with multipart content where the image is included in a part with 'Content-Transfer-Encoding: binary' and is therefore not base64 encoded.

I am not doing this exact thing, but I am doing the reverse in a sense, where I am submitting an HTTP POST to my server that contains multipart content, where one part is audio data. I am just sending that in raw form in a section that uses binary for Content-Transfer-Encoding. If you are in control of the code both sending and receiving I don't see why you would need to do base64 encoding.
__________________
My Apps - Carbfinder, My BG Lite
beachdog is offline   Reply With Quote
Old 05-19-2009, 11:09 PM   #6 (permalink)
[self setSkills: ∞];
 
Join Date: Dec 2008
Age: 28
Posts: 111
Default

I guess what I'm asking is, is there a way to receive the images inline as an element in the XML document, and then parsed by the NSXMLParser? Or would images need to be downloaded and handled separately?
__________________
Want a free copy of my MMS app? http://www.iphonedevsdk.com/forum/pr...plication.html
cjpearl is offline   Reply With Quote
Old 05-20-2009, 08:52 AM   #7 (permalink)
New Member
 
Join Date: Jan 2009
Posts: 36
Default

Quote:
Originally Posted by cjpearl View Post
I guess what I'm asking is, is there a way to receive the images inline as an element in the XML document, and then parsed by the NSXMLParser? Or would images need to be downloaded and handled separately?
I would think you could have the images contained in the XML document. You would just want to have them in a CDATA section that contains the binary data.
__________________
My Apps - Carbfinder, My BG Lite
beachdog is offline   Reply With Quote
Old 05-20-2009, 09:32 AM   #8 (permalink)
Apple Evangelist
 
sukumar_77's Avatar
 
Join Date: Aug 2008
Location: Mumbai
Posts: 196
Default

Quote:
Originally Posted by beachdog View Post
I would think you could have the images contained in the XML document. You would just want to have them in a CDATA section that contains the binary data.
XML may contain encoded binary data or it may contain just the url for the images which can be then used to download.
__________________
- Sushil
sukumar_77 is offline   Reply With Quote
Old 05-20-2009, 01:17 PM   #9 (permalink)
[self setSkills: ∞];
 
Join Date: Dec 2008
Age: 28
Posts: 111
Default

Yeah, it looks like embedding the binary data directly into the XML document will be a problem for the parser. I could either embed the URLs (which might be difficult since the images will be contained as BLOBs in an SQL database), or base64 encode the images in the PHP form I use to query the database, embed them in the XML document, send the whole thing back to the phone's XML parser, and use a base64 decoder class in Cocoa to bring the images back to data I can use.

Thanks guys!
__________________
Want a free copy of my MMS app? http://www.iphonedevsdk.com/forum/pr...plication.html
cjpearl 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: 416
9 members and 407 guests
AppleSteve, banatary70, chiataytuday, DaveDee, Domele, ilmman, Jameswhitfield, johnRambo, Objective Zero
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 157,854
Threads: 88,915
Posts: 379,298
Top Poster: BrianSlick (7,072)
Welcome to our newest member, Jameswhitfield
Powered by vBadvanced CMPS v3.1.0

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