Objective-C ,ios,iphone开发基础:http网络编程
2013-09-05 18:55
525 查看
- (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]; }
相关文章推荐
- Objective-C ,ios,iphone开发基础:http第三方库 ASIHttpRequest简介
- Objective-C ,ios,iphone开发基础:http第三方库 ASIHttpRequest简介
- iOS 开发之 网络编程(HTTP协议,NSURL-get post)
- Objective-C ,ios,iphone开发基础:JSON解析(使用苹果官方提供的JSON库:NSJSONSerialization)
- iOS开发笔记4:HTTP网络通信及网络编程
- Objective-C ,ios,iphone开发基础:如何判断一个字符是不是中文字符。计算一段字符串的长度。
- Objective-C ,ios,iphone开发基础:使用第三方库FMDB连接sqlite3 数据库,实现简单的登录
- Objective-C ,ios,iphone开发基础:ios数据库(The SQLite Database),使用终端进行简单的数据库操作
- Objective-C ,ios,iphone开发基础:ios获取大文件的MD5值
- iOS开发 - 网络编程之HTTP协议
- Objective-C ,ios,iphone开发基础:JSON解析(使用苹果官方提供的JSON库:NSJSONSerialization)
- Objective-C ,ios,iphone开发基础:协议(protocol)
- iOS开发网络-网络编程基础
- Objective-C ,ios,iphone开发基础:多个视图(view)之间的切换,以及视图之间传值。使用parent <->dismiss
- Objective-C ,ios,iphone开发基础:UIAlertView使用详解
- Objective-C ,ios,iphone开发基础:3分钟教你做一个iphone手机浏览器
- Objective-C ,ios,iphone开发基础:在UITextField输入完以后,隐藏键盘,
- Objective-C ,ios,iphone开发基础:多个视图(view)之间的切换,以及视图之间传值。
- Objective-C ,ios,iphone开发基础:UIAlertView使用详解
- [置顶] Objective-C ,ios,iphone开发基础:UIAlertView使用详解