38
38

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

SwiftでシンプルにPOST/GET/PUT/DELETEするライブラリ

Posted at

githubでもswiftのライブラリ系が活発になってますね。
本日発見したライブラリはこちら

##hallas/agent
https://github.com/hallas/agent
ライセンスはMIT

#使い方
こちらもまだPodに対応していないようなのでダウンロードして、Agent.swiftをプロジェクトに投げ込んで利用開始。

#記述例

##POST(url: String)

let req = Agent.post("http://example.com")
req.send([ "Key": "Value" ])
req.end({ (response: NSHTTPURLResponse!, data: Agent.Data!, error: NSError!) -> Void in
  // react to the result of your request
})

##GET(url: String)

let req = Agent.get("http://example.com")
req.end({ (response: NSHTTPURLResponse!, data: Agent.Data!, error: NSError!) -> Void in
  // react to the result of your request
})

GETはreq.send([ "Key": "Value" ])には対応していない模様

##PUT(url: String)

let req = Agent.put("http://example.com")
req.send([ "Key": "Value" ])
req.end({ (response: NSHTTPURLResponse!, data: Agent.Data!, error: NSError!) -> Void in
  // react to the result of your request
})

##DELETE(url: String)

let req = Agent.delete("http://example.com")
req.end({ (response: NSHTTPURLResponse!, data: Agent.Data!, error: NSError!) -> Void in
  // react to the result of your request
})
38
38
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
38
38

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?