Objective C - POST data using NSURLConnection

后端 未结 4 999
独厮守ぢ
独厮守ぢ 2021-02-10 17:33

I\'m very slowly working my way through learning the URL loading system for iOS development, and I am hoping someone could briefly explain the following piece of code:



        
4条回答
  •  有刺的猬
    2021-02-10 18:30

    The first line created an string, it can be replaced with:

    NSString *myParameters = @"one=two&three=four";
    

    It's written in initWithFormat so you can extend it to assign parameter value.

    Second line indicate this is HTTP post request.

    The third line, setHTTPBody method take NSData type, so you need to convert string type to NSData using dataUsingEncoding method.

提交回复
热议问题