iPhone开发应用ASIHTTPRequest如何获取文件流

移动开发 iOS
iPhone开发应用ASIHTTPRequest如何获取文件流是本文要介绍的内容,主要讲解的是如何获取文件流,来看本文详细代码实现。

iPhone开发应用ASIHTTPRequest如何获取文件流是本文要介绍的内容,主要讲解的是如何获取文件流,内容不多,主要是基于代码来实现文件流的获取,不多说,来看详细代码。在服务器上获取文件中的内容,此例中的文件为TXT文件

  1. - (void)getContact{  
  2. NSString *host = [[NSUserDefaults standardUserDefaults]objectForKey:@"HOST"];  
  3. ASIHTTPRequest *m_request = [[ASIHTTPRequest alloc]initWithURL:  
  4.    [NSURL URLWithString:[NSStringstringWithFormat:@"%@:8090/contact.txt",host]]];  
  5. [m_request setDelegate:self];  
  6. [m_request setDidFailSelector:@selector(ASIHttpRequestFailed:)];  
  7. [m_request setDidFinishSelector:@selector(ASIHttpRequestSuceed:)];  
  8. [m_request startAsynchronous];  
  9. }  
  10.  
  11. - (void)ASIHttpRequestFailed:(ASIHTTPRequest *)m_request{  
  12. [self hideDial];  
  13. if (m_request) {  
  14. [m_request release];  
  15. }  
  16. }  
  17.  
  18. - (void)ASIHttpRequestSuceed:(ASIHTTPRequest *)m_request{  
  19. NSData *data = [m_request responseData];  
  20.  
  21. if (data)   
  22. {  
  23. NSString *string = [[NSString alloc] initWithData:dataencoding:NSUTF8StringEncoding];  
  24. NSLog(@"%@",string);  
  25. [contact clean];  
  26. if (string)   
  27. {  
  28. [contact storeContacts:string Source:1];  
  29. }  
  30. [string release];  
  31. }  
  32. if (m_request) {  
  33. [m_request release];  
  34. }

小结:关于iPhone开发应用ASIHTTPRequest如何获取文件流的内容介绍完了,希望本文对你有所帮助!

责任编辑:zhaolei 来源: 互联网
相关推荐

2011-08-10 17:37:00

iPhoneASIHTTPRequ

2011-08-11 13:35:28

iPhoneASIHTTPRequHTTP

2011-08-19 14:34:03

iPhone开发

2011-08-12 14:33:06

iPhone缓存文件

2013-07-22 14:10:26

iOS开发ASIHTTPRequ

2013-07-21 18:22:59

iOS开发ASIHTTPRequ

2013-07-22 14:38:00

iOS开发ASIHTTPRequ

2013-07-21 18:18:00

iOS开发ASIHttpRequ

2013-07-21 18:27:15

iOS开发ASIHTTPRequ

2011-08-03 17:44:57

iPhone App 文件

2011-08-08 10:10:14

iPhone开发 图片 方法

2011-08-09 17:29:29

iPhone文件屏幕

2011-08-08 16:56:44

iPhone 字符处理 视图

2011-08-10 10:10:21

iPhoneUIPopoverCo

2013-07-22 14:33:15

iOS开发ASIHTTPRequ

2013-07-22 14:15:17

iOS开发ASIHTTPRequ

2013-07-21 18:32:13

iOS开发ASIHTTPRequ

2013-07-22 13:54:32

iOS开发ASIHTTPRequ

2011-08-17 15:10:21

iPhone开发Web视图

2011-07-19 09:58:36

点赞
收藏

51CTO技术栈公众号