POST with NSURLConnection - NO JSON

前端 未结 3 907
攒了一身酷
攒了一身酷 2021-02-06 17:35

I am trying to write an iPhone app in Objective-C. I need to POST data using NSURLConnection. Every example I can find deals with JSON; I do not need to use JSON. All I need to

3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-06 18:12

    I've a very similar situation to whitebreadb. I'm not disagreeing with the answers submitted and accepted but would like to post my own as the code provided here didn't work for me (my PHP script reported the submitted parameter as a zero-length string) but I did find this question that helped.

    I used this to perform a posting to my PHP script:

    NSURL *URL = [NSURL URLWithString:[NSString stringWithFormat:@"http://www.myphpscriptlocation.net/index.php?userID=%@",self.userID_field.stringValue]];
    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:URL];
    request.HTTPMethod = @"POST";
    NSURLConnection *c = [NSURLConnection connectionWithRequest:request delegate:self];
    

提交回复
热议问题