views:

39

answers:

2

I have a photogallery in my app that I want users to be able to comment on, adding funny captions, and I want users to be able to click Thumbs Up or Thumbs Down.

What is the best way to store and load the comments and thumbsup/down information? I'm a bit of a noob to the iOs and am assuming I would have my own website hosting a mysql database that would store a table for comments and for thumbsup/down. And i would write to that when a user makes a new comment and read from that on app load. I havent found much info from my googles. Any help with direction or articles to read would be appreciated.

Also, how would I make the app just download the new comments?

A: 

In a recent app I implemented a similar feature. I accomplished it by implementing php scripts on the server which would fetch or write data from / to a mysql database. The app would just perform an URLRequest to the proper php file and pass some arguments along as variables in the url. The php script would then return xml data containing the comments and other data, which the request would read and output as NSData. The app could then parse the xml data. From there on it's up to you what you do with it.

Edit: you might want to take a look at this SO question and answer I asked on the matter..

Toastor
A: 

I recommend creating a web service for your app to interface with. Your service will basically have five functions: add comment, add caption, thumbs up/down, get photo info, and get new comments. Your app will send a request to your web service for one of the five functions, and pass along any relevant data. Your service will listen for requests, and update the database accordingly whenever a request is made. The 'get photo' function will return all of the information associated with one or more photos (photo, comments, caption, etc).

As far as your database goes, I would suggest a Photos table that holds PhotoID (primary key), ImageLocation, ThumbsUpDown (integer), etc. Comments and captions will require two additional tables that both relate to the Photos table on PhotoID (foreign key).

Only downloading the new comments will be a little more work to pull off, and may require your app to communicate with the web service which comments it has already received. This will become more complicated if you are going to be editing/removing comments. I would recommend starting with the basics, and have all comments transferred upon request.

I've tried to keep this fairly basic - a more robust app will, of course, require more functions and more fleshed-out table structures.

Jonathan