swift 使用 AFHTTPRequestOperationManager

前端之家收集整理的这篇文章主要介绍了swift 使用 AFHTTPRequestOperationManager前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。


let url = "http://www.baidu.com"

let params = ["lat": 39.26,"lon": 41.03,"cnt":0]

let arr = ["","",""]

var type="text/plain"

var sets=NSSet()

var manager = AFHTTPRequestOperationManager()

manager.responseSerializer.acceptableContentTypes = sets.setByAddingObject(type)

manager.requestSerializer = AFHTTPRequestSerializer()

manager.responseSerializer = AFJSONResponseSerializer()

manager.POST(url,parameters: params,success: { (operation:AFHTTPRequestOperation!,responSEObject: AnyObject!) in


println("JSON: " + responSEObject.description!)

},

failure: { (operation: AFHTTPRequestOperation!,error: NSError!) in

println("Error: " + error.localizedDescription)

})

猜你在找的Swift相关文章