Encoding spaces in UITextView / UITextField to URL format

前端 未结 3 611
情深已故
情深已故 2020-12-31 18:18

I\'m trying to send the contents of UITextView or UITextField as parameters to a php file

NSString *urlstr = [[NSString alloc] initWithFormat:@\"http://serve         


        
3条回答
  •  感动是毒
    2020-12-31 18:43

    You can take your URL and use:

    NSString *urlStr = [[NSString alloc] initWithFormat:@"http://server.com/file.php?name=%@&tags=%@&entry=%@",nameField.text, tagsField.text, dreamEntry.text];
    
    NSString *encStr = [urlStr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    

提交回复
热议问题