开发者

iOS: tableview app and database

I want to create a jokes application where jokes can be voted up and down and have ratings.

There is also different categories for the jokes.

My question is how should I store the jokes database?

The jokes database will be growing as application is updated. Do I want to store it on the phone or let the users grab the joke off a database in the web?

If the first option, what is the maximum capacity of text can I store on the iOS app? (In this case, I assume that jokes database will be updated as I update the app) If the 开发者_开发问答second option, how is this done? I can think of a couple of options, but they aren't really good. 1. store the database on a webpage and just grab it from there (but users cant vote up and down on the jokes) 2. create a mobile website that has all the jokes implemented like a real website, and use webview to show the jokes page to the user. (will probably need a log in system so users cant abuse the votes) In these two cases, it is unsafe, because someone can just find out where my jokes are hosted by doing a google search and take all my content.

What do you recommend?


The most scalable solution is to build your own backend and fetch data from it on the phone. Application updates should be used for deploying code updates, not content updates. If you want a growing database of jokes to be available to the user, you're going to need a database stored somewhere on the web.

This approach requires you to set up your own webserver with a jokes database (using something like SQL or Postgres). You can use PHP, Ruby on Rails, Django, or other such server-side technologies to process incoming requests and fetch data from the database. The server would then vend this data back to the phone in a network-friendly format like JSON.

On the iPhone side, you can use NSURLRequest and NSURLRequestDelegate to make an asynchronous request to the server. For example, if you wanted to fetch all the jokes from the backend, you might make a GET request to http://www.yoursite.com/jokes. The backend will receive the request, use SQL queries to fetch the jokes, format the data as JSON, and send it back over the network to the phone. The phone can then parse the JSON (there a numerous JSON libraries for Cocoa Touch development) and update the display. To allow users to vote on jokes, you can similarly make POST requests to the backend, which will modify the data in the database.

Here's a simple example of how to work with JSON on the iPhone side: http://mobile.tutsplus.com/tutorials/iphone/iphone-json-twitter-api/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜