cool hit counter Use of Alamofire, a triad for network requests in iOS development_Intefrankly

Use of Alamofire, a triad for network requests in iOS development


Copyright: This is an original post by the blogger and may not be reproduced without the blogger's permission. https://blog.csdn.net/u010105969/article/details/80268579

Most of the network request classes in OC development we will use AFNetworking, and the more well-known network request triad in swift is Alamofire.

Usage.

Alamofire

Reproducible code.

func postRequest(urlStr:String, parameters:Parameters, finishCallBack:@escaping(_ responseObject:AnyObject?, _ error:Error?) -> ()) { Alamofire.request(urlStr, method: .post, parameters: parameters).responseJSON { (returnResult) in print("secondMethod --> POST requesting --> returnResult = (returnResult)") // Determining if a network request is in error if returnResult.result.isSuccess{ print(" success...") print("===============(returnResult.result)") finishCallBack(returnResult.result as AnyObject, returnResult.error) if let value = returnResult.result.value{ print("value:====(value)") let json = JSON(value) // JSON Data to objects let user = json["data"]["niu_index_response"] print(user) // Dictionary to model let personModel = Permodel.init(json: user) print(personModel.nickname) } }else{ print(" make a mistake...") print(returnResult.result.error!) finishCallBack(returnResult.result as AnyObject, returnResult.error) } } }

I use Alamofire and use AFNetworking is the same idea, after the network request is successful a callback is made to the requested data and passed back to the current class using the network request. The data is parsed using SwiftyJSON, a three-party library that converts JSON data into objects (typically dictionaries or arrays).

That concludes this post, may you all work less overtime for more pay, and have girlfriends for all gays and boyfriends for all women.


Recommended>>
1、Python Batch Download Emoticons
2、PyTorch 10 rocks
3、NVIDIA releases worlds largest GPU with 10x performance boost
4、Blockchain Discourse the real marriage between blockchain and business is in the incentives
5、Python crawler data extraction

    已推荐到看一看 和朋友分享想法
    最多200字,当前共 发送

    已发送

    朋友将在看一看看到

    确定
    分享你的想法...
    取消

    分享想法到看一看

    确定
    最多200字,当前共

    发送中

    网络异常,请稍后重试

    微信扫一扫
    关注该公众号