开发者

get JSON / XML from Rails to iOS (xcode 4) table view

We tried some ways but with no luck. So post t开发者_如何学运维o here to ask for help.

We have a rails application which could generate XML and JSON responses (some restful routes and some custome routes).

And we want to get and post data from and to the rails app from a iphone application (using xcode 4).

Those data would be feed into a table view for reading.

So consider the rails app would give a list of posts with title and content in XML or JSON structure,

the ios app could read the data by the url http://host.com/posts.(xml or json),

and the table view would display the post title in a normal table view.

Any help would be appreciated.

As we are new to ios development, the more detail the more better! Thanks!


There's a framework for that: JSON Framework. You can find examples in the git repository. Another tutorial: How to parse JSON files on iPhone in Objective-C into NSArray and NSDictionary

NSDictionary is very similar in the structure to JSON, so it's easy to put them together. And you can generate NSArrays out of the dictionary for your NSTableView.


Since you are dealing with a Rails backend RestKit should definitely be your preferred choice.

It was built initially with the specific purpose of communicating with Rails, and includes things such as object mapping (huge benefit and time saver) and Core Data support. It also has some of the most comprehensive documentation I've seen in an open source framework.

RestKit is very aggressively developed and has an extremely active Google Group on which the frameworks developers are ever present.


Have you looked at objective resource yet http://iphoneonrails.com/

Not done this for a while but I remember it was a good place to start.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜