简体   繁体   English

iPhone的TextView内容到URL?

[英]iphone textview contents to url?

我怎么能有一个uitextview值并仅使用obj-c发送到预定义的url而没有任何html / php。

Take a look at NSURL. 看一下NSURL。 Use the text value of the UITextView as a parameter. 使用UITextView的文本值作为参数。

eg 例如

NSURL *webURL = [NSURL URLWithString:MY_TEXTVIEW.text];
NSURLRequest *req = [NSURLRequest requestWithURL:webURL];
NSString *methodString = @"method";
NSString *parameterString = [NSString stringWithFormat:@"value=%@", textField.text];
NSString *apiRoot = @"http://www.domain.com";   
NSURL *apiUrl = [NSURL URLWithString:[NSString stringWithFormat:@"%@/%@?%@", apiRoot,methodString,parameterString]];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:apiUrl];
NSURLResponse *response = nil;
NSError *error = nil;
NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM