Objective-C ,ios,iphone开发基础:http网络编程
作者:互联网
原文链接:http://www.cnblogs.com/wsq724439564/p/3304031.html
- (IBAction)loadData:(id)sender { NSURL* url = [NSURL URLWithString:@"http://162.105.65.251:8080/service/downloadusernote?user_name=weishouqiang"]; NSURLRequest* request = [[NSURLRequest alloc] initWithURL:url]; NSURLConnection* conn = [[NSURLConnection alloc] initWithRequest:request delegate:self]; [conn release]; [request release]; [upTextView resignFirstResponder]; [downTextView resignFirstResponder]; } - (IBAction)upLoad:(id)sender { NSData* upData = [upTextView.text dataUsingEncoding:NSUTF8StringEncoding]; NSURL* url = [NSURL URLWithString:@"http://162.105.65.251:8080/service/uploadusernote?user_name=weishouqiang"]; NSMutableURLRequest* request = [[NSMutableURLRequest alloc] initWithURL:url]; [request setHTTPMethod:@"POST"]; [request setValue:[NSString stringWithFormat:@"%ld",[upData length]]forHTTPHeaderField:@"Content-Length"]; [request setHTTPBody:upData]; NSURLConnection* conn = [[NSURLConnection alloc] initWithRequest:request delegate:self]; [conn release]; [request release]; [upTextView resignFirstResponder]; [downTextView resignFirstResponder]; }
转载于:https://www.cnblogs.com/wsq724439564/p/3304031.html
标签:alloc,http,resignFirstResponder,ios,request,iphone,NSURLConnection,conn 来源: https://blog.csdn.net/weixin_30399055/article/details/97535722