DIOS 4.1.1

DIOS 4.1.1

测试已测试
语言语言 SwiftSwift
许可 自定义
发布最后发布2016年8月
SPM支持 SPM

Kyle Browning维护。



 
依赖关系
Alamofire>= 0
SwiftyJSON>= 0
 

DIOS 4.1.1

  • 作者
  • Kyle Browning

Drupal iOS SDK - 将您的 iOS/OS X 应用连接到 Drupal

Kyle Browning制作

简介

Drupal iOS SDK 是从任何 iOS 设备与 Drupal 通信的标准库集。它非常简单,基本上是 Alamofire 的包装。它结合了与 Drupal 通信时用到的最常用的命令,并为您处理会话管理。

要求

DIOS 版本 Drupal 版本 最小 iOS 目标 说明
4.x Drupal 8(Swift) iOS 9.0
3.x Drupal 8(Obj-C) iOS 7.0
2.x Drupal 6-7(Obj-C) iOS 5.0 需要 Services 模块

哲学和目标

在核心上,Drupal iOS SDK 被设计用来处理 Drupal 核心支持的所有内容。由于 8.x 尚处于起步阶段,随着 Drupal 旨在提高其 API 功能,越来越多的功能将变为可用。

当前 4.x 功能

  • 会话管理
  • 实体Crud

未来

未来,此项目将提供更多强大的功能,这些功能将使从 Swift 视角与 Drupal 一起工作变得更加容易,例如

  • LoginViewController
  • SignupViewController
  • LogoutButton
  • 将视图集成到表格视图中

安装


创建一个 pod 文件(这将使您保持在 4.0 版本,这是 Drupal 8 特定的)

 pod 'DIOS', '~> 4.0'

然后运行

pod install

配置

  1. 从该存储库复制 plist 文件或创建一个并命名为 dios.plist
  2. 修改 diosurlkey 以指向您的域名
  3. (可选) 如果您不使用HTTPS,您需要启用http://stackoverflow.com/questions/31254725/transport-security-has-blocked-a-cleartext-http

初始化步骤

以下代码将为您提供与Drupal站点的通信功能基线访问权限。

//Create an instance to use.
let dios = DIOS.sharedInstance

这将登录到该网站。

//set Username and password
dios.setUserNameAndPassword("kylebrowning", password: "password")

实体请求

//we need an entity manager instance
let em = DIOSEntity()

获取

let em = DIOSEntity()

//Get Node 36
em.get("node", entityId: "36") { (success, response, json, error) in
    if (success) {
        print(json)
    } else {
        print(error)
    }
}

创建/发表

//build our node body
let body = [
    "type": [
        [
            "target_id": "article"
        ]
    ],
    "title": [
        [
            "value": "Hello World"
        ]
    ],
    "body": [
        [
            "value": "How are you?"
        ]
    ]
]

//Create a new node.
em.post("node", params: body) { (success, response, json, error) in
    if (success) {
        print(response)
    } else {
        print(error)
    }
}

更新/PUT/PATCH

//Update an existing node
em.patch("node", entityId: "36", params: body) { (success, response, json, error) in
    if (success) {
        //Extra error checking, but its not needed
        if (response!.response?.statusCode == 201) {
            print(json)
        }
    } else {
        print(error)
    }
}

删除

//Delete an existing node
em.delete("node", entityId: "26") { (success, response, json, error) in
    if (success) {
        print(response)
    } else {
        print(error)
    }
}