0
我正在使用树屋库学习iOS开发。构建一个从json API获取信息的应用程序。使用我的Rails应用程序API for iPhone应用程序
在树API页面所有的职位都被称为父下的 “帖子”(http://blog.teamtreehouse.com/api/get_recent_summary/)
posts: [
{
id: 22198,
url: "http://blog.teamtreehouse.com/using-github-pages-to-host-your-website",
title: "Using GitHub Pages To Host Your Website",
date: "2013-08-16 09:30:20",
author: "Matt West",
thumbnail: "http://blog.teamtreehouse.com/wp-content/uploads/2013/08/github-pages-feature-150x150.jpg"
},
{
id: 22196,
url: "http://blog.teamtreehouse.com/running-tests-in-ruby-on-rails-treehouse-quick-tip",
title: "Running Tests in Ruby on Rails – Treehouse Quick Tip",
date: "2013-08-15 14:30:48",
author: "Jason Seifer",
thumbnail: null
},
从我的Rails应用可是没有一个家长的API(http://www.soleresource.com/releases.json)
[
{
shoe_name: "Air Jordan 4 "Green Glow"",
release_date: "2013-08-17T00:00:00.000Z",
shoe_colorway: "Dark-Grey/Green-Glow",
shoe_price: "160",
url: "http://www.soleresource.com/releases/8.json"
},
{
shoe_name: "Nike Barkley Posite",
release_date: "2013-08-17T00:00:00.000Z",
shoe_colorway: "Gamma-Green/Black",
shoe_price: "235",
url: "http://www.soleresource.com/releases/17.json"
},
为了让应用程序工作,我必须打电话给父(帖子),像这样:
self.upcomingReleases = [dataDictionary objectForKey:@"posts"];
如何将我的API“包装”到父项下? (我的模型被称为“发布”)
谢谢你,我会考虑这样做。 – ChrisBedoya
,或者在你的rails控制器中执行如下操作:'render json:releases:@ releases' – macool