ObjectiveHAL 1.2.4

ObjectiveHAL 1.2.4

测试测试过的
Lang语言 Obj-CObjective C
许可证 MIT
发布最新发布2014年12月

Bennett Smith维护。



 
依赖关系
CSURITemplate>= 0
AFNetworking~> 1.3
 

  • Bennett Smith

文档状态:不完整;目前请查看代码和/或单元测试。

此Objective-C的实现是JSON Hypertext Application Language Internet-Draft。

安装

CocoaPods是使用ObjectiveHAL的最简单方法。

platform :ios, '6.1'
pod 'ObjectiveHAL'

示例

ObjectiveHAL依赖于AFNetworking库进行网络操作。具体来说,ObjectiveHAL的使用者预计在创建任何链接遍历操作时构造一个AFHTTPClient并将指向它的指针传递。

所有示例都基于以下HAL文档

{
  "_links": {
    "curies": [
      {
        "href": "http://tempuri.org/rels/{rel}",
        "name": "r",
        "templated": "true"
      },
      {
        "href": "http://tempuri.org/rels/app/{rel}",
        "name": "app",
        "templated": "true"
      },
      {
        "href": "http://tempuri.org/rels/asset/{rel}",
        "name": "asset",
        "templated": "true"
      }
    ],
    "self": {
      "href": "/app/2"
    },
    "app:icon": {
      "href": "/icon/2"
    }
  },
  "_embedded": {
    "app:icon": {
      "_links": {
        "self": {
          "href": "/icon/2"
        },
        "asset:small_image": {
          "href": "/images/i310.png"
        },
        "asset:large_image": {
          "href": "/images/i223.png"
        }
      }
    }
  },
  "name": "High Altitude Survival (resource)",
  "synopsis": "A series of short films that illustrate some of the dangers inherent in high altitude mountainering and discuss life-saving survival techniques."
}

从某些JSON创建HAL资源

// Fetch JSON somehow.
id json = [NSJSONSerialization JSONObjectWithData:data options:0 error:&error];

// Construct HAL resource.
OHResource *resource = [OHResource resourceWithJSONData:json];

访问资源属性

待续...