Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

neiltc13

macrumors 68040
Original poster
May 27, 2006
3,128
28
I'm pretty beginner at iPhone coding and my application idea involves retrieving data from a server. While devising it, I had thought that it would be sufficient to store it in a MySQL database and hoped that iPhone would have a way of handling this.

However, I don't think that's possible. All I really want to do is download specific contents of a database as they are needed. So when a user switches from one page to another in my application, I want it to propagate that page with data.

Can anyone give me some pointers on the best way to do this? I had a look on the developer pages at Apple.com but it seems to involve storing a .sql file on the phone itself.
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
Well you have all the normal networking functions so you could write a "library" to access MySQL via whatever protocol it uses. Easier though would be to write some code in your favourite language (Java/Ruby/PHP/whatever) and present a http-based front-end to the data...
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
How would you do that?

The server side is up to you. I would suggest returning XML data, but that is not iPhone specific and you should use whatever you are comfortable with. The iPhone side is covered in by using well documented (and discussed on here) NSURLConnection class. Once you have the data it's up to you how you parse it/deal with it.
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate

If you do a search in this forum I think there are examples of using this. I'd recommend staying away from the simpler looking synchronous call and go with the async delegate-based methods. It's a bit more work but the sync method leaks memory :p
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.