开发者

iphone textview contents to url?

开发者 https://www.devze.com 2023-02-03 19:45 出处:网络
How can i have a uitextview value be taken and send to a predefined url using o开发者_开发技巧bj-c only without any html /php.Take a look at NSURL. Use the text value of the UITextView as a parameter.

How can i have a uitextview value be taken and send to a predefined url using o开发者_开发技巧bj-c only without any html /php.


Take a look at NSURL. Use the text value of the UITextView as a parameter.

e.g.

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];
0

精彩评论

暂无评论...
验证码 换一张
取 消