SwiftHTTP 简单封装了 Swift 语言中的 NSURLSession ,简化了 HTTP 请求操作。
示例代码:
var request = HTTPTask() request.GET("http://www.oschina.net/", parameters: nil, success: {(response: AnyObject?) -> Void in if response { let data = response as NSData let str = NSString(data: data, encoding: NSUTF8StringEncoding) println("response: \(str)") //prints the HTML of the page } },failure: {(error: NSError) -> Void in println("error: \(error)") })