What does the SWIFT server require for JSON objects? A

Source: Internet
Author: User

Online This three class library is about to see vomit, swifthttp,yyhrquest,afnetworking;http request is nothing more than call these class library of put,get,post,delete, which need our brains is probably the parameter of the pass,


A: Put and delete, the same way, directly behind the URL stitching &parameter on it, such as Http://10.111.11.11:8088/api/?sqlname=GET_ALL&name=dog &password=123

You can, of course, use the dictionary provided by the class library to put parameters

When using the Swifthttp

var request = Httptask ()          var parameters:dictionary<string,string>=["name": "Dog", "password": "123"]request . GET ("Http://10.111.11.11:8088/api/?sql=GET_ALL", Parameters:nil, Success: {(response:httpresponse), Void in If Response.responseobject! = Nil {println ("Success")}},failure: {(Error:nserror, _), Void in println ("false")})

</pre><pre>
Two: What about post and put? What if the server does not recognize the word typical? (Oh, what a fuck day)

All I can say is a quiet conversion.

<pre name= "code" class= "OBJC" > Public func POST (url:string, parameters:dictionary<string,anyobject>, Success: ((HttpResponse)-void)!, failure: ((Nserror, HttpResponse?), void)!) {                        //var opt =            var opt = self.create (URL, method:. POST, parameters:parameters,success:success,failure:failure)                if opt! = nil {            opt!. Start ()        }    }    

This is swifthttp in the post way, look good, but this word typical parameter server does not know him as long as the JSON type, OK, the mountain does not turn the water turn, the water does not turn the person, I do not need this

Three: I want to use yyhrequest this class library to try, (looks good cottage name, but the advantage is you can transform him)

Func post (strpara:[string],strusername:string,strpassword:string) {let          request = Yyhrequest (Url:nsurl (String: " Http://10.11.11.1:8088/api/?sql=UPDATE1 "  var parameterstr:string =" "Request.method =" POST "  // The following is a demo, and then there is no egg, the server or do not know      request.parameters["name"] = "dog"       request.parameters["password"] = " 123 "//So write server really know, just think this is JSON, I am also drunk        parameterstr=" {' Name ': ' Dog ', ' password ': ' 123 '} "        request.parameters[" " ] = Parameterstr                Request.completionhandler = {response, data, error in                   }       request.loadrequest ()                   }


Well, after the use of the above post can finally plug into the database, haha, this parameter is too simple, I also think, to a nested, good, you see the next period!


What does the SWIFT server require for JSON objects? A

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.