Perform POST request in Swift

后端 未结 2 1274
轻奢々
轻奢々 2021-01-31 20:27

I am trying to do something like this:

NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@\"http://google.com\"]];

request         


        
2条回答
  •  借酒劲吻你
    2021-01-31 21:11

    stringByAddingPercentEscapesUsingEncoding returns a string instead of an NSData object. According to this answer, you need to use this to convert to an NSData instance:

    let data = (anySwiftString as NSString).dataUsingEncoding(NSUTF8StringEncoding)
    

提交回复
热议问题