偷偷摘套内射激情视频,久久精品99国产国产精,中文字幕无线乱码人妻,中文在线中文a,性爽19p

iPhone開發(fā)應(yīng)用ASIFormDataRequest POST操作架構(gòu)設(shè)計

移動開發(fā) iOS
iPhone開發(fā)應(yīng)用中ASIFormDataRequest POST操作架構(gòu)設(shè)計是本文喲啊介紹的內(nèi)容,主要是來講述ASIFormDataRequest的POST操作架構(gòu)設(shè)計,方法由自己定義。

iPhone開發(fā)應(yīng)用中ASIFormDataRequest POST操作架構(gòu)設(shè)計是本文喲啊介紹的內(nèi)容,主要是來講述ASIFormDataRequest的POST操作架構(gòu)設(shè)計,方法由自己定義。內(nèi)容主要是基于代碼來實現(xiàn),來看詳細(xì)代碼。

  1. //開啟iphone網(wǎng)絡(luò)開關(guān)  
  2. [UIApplication sharedApplication].networkActivityIndicatorVisible = YES;  
  3. ASIFormDataRequest *request = [[ASIFormDataRequest alloc] initWithURL:[NSURLURLWithString:host]];  
  4. //超時時間  
  5. request.timeOutSeconds = 30;  
  6. //定義異步方法  
  7. [request setDelegate:self];  
  8. [request setDidFailSelector:@selector(requestDidFailed:)];  
  9. [request setDidFinishSelector:@selector(requestDidSuccess:)];  
  10.  
  11. //用戶自定義數(shù)據(jù)   字典類型  (可選)  
  12. request.userInfo = [NSDictionary dictionaryWithObject:method forKey:@"Method"];  
  13. //post的數(shù)據(jù)  
  14. [request appendPostData:[body dataUsingEncoding:NSUTF8StringEncoding]];  
  15. //開始執(zhí)行  
  16. [request startAsynchronous];  
  17. //執(zhí)行成功  
  18. - (void)requestDidSuccess:(ASIFormDataRequest *)request  
  19. {  
  20. //獲取頭文件  
  21. NSDictionary *headers = [request responseHeaders];  
  22. //獲取http協(xié)議執(zhí)行代碼  
  23. NSLog(@"Code:%d",[request responseStatusCode]);  
  24. if ([delegaterespondsToSelector:@selector(OARequestSuccessed:withResponse:WithData:withHeaders:)])  
  25. {  
  26. //執(zhí)行委托操作  (架構(gòu)設(shè)計   自選)  
  27. [delegate OARequestSuccessed:method withResponse:[request responseString]WithData:[request responseData] withHeaders:headers];  
  28. }  
  29. //清空  
  30. if (request)  
  31. {  
  32. [request release];  
  33. }  
  34. //關(guān)閉網(wǎng)絡(luò)  
  35. [UIApplication sharedApplication].networkActivityIndicatorVisible = NO;  
  36. }  
  37. //執(zhí)行失敗  
  38. - (void)requestDidFailed:(ASIFormDataRequest *)request{  
  39.  
  40. //獲取的用戶自定義內(nèi)容  
  41.  
  42. NSString *method = [request.userInfo objectForKey:@"Method"];  
  43. //獲取錯誤數(shù)據(jù)  
  44. NSError *error = [request error];  
  45. if ([delegate respondsToSelector:@selector(OARequestFailed:withError:)])   
  46. {  
  47. //執(zhí)行委托 將錯誤數(shù)據(jù)傳其他方式(架構(gòu)設(shè)計   自選)  
  48. [delegate OARequestFailed:method withError:error];  
  49. }  
  50. if (request)   
  51. {  
  52. [request release];  
  53. }  
  54. [UIApplication sharedApplication].networkActivityIndicatorVisible = NO;  
  55. }  
  56.  
  57. //執(zhí)行成功函數(shù)  
  58.  
  59. - (void)OARequestSuccessed:(NSString *)method withResponse:(NSString *)response WithData:(NSData *)data withHeaders:(NSDictionary *)headers  
  60. {  
  61. NSString *responseStr = [[[NSString alloc] initWithData:dataencoding:NSUTF8StringEncoding] autorelease];  
  62. //服務(wù)返回post后的數(shù)據(jù)  
  63. NSLog(@"response:\n%@",responseStr);  
  64. }  
  65.  
  66. //執(zhí)行失敗函數(shù)  
  67. - (void)OARequestFailed:(NSString *)method withError:(NSError *)error  
  68. {  
  69. NSLog(@"Error:%@",error);  
  70. UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"出錯了" message:@"網(wǎng)絡(luò)連接失敗, 請稍后重試." 
  71. delegate:nil cancelButtonTitle:@"好的" otherButtonTitles:nil];  
  72. [alert show];  
  73. [alert release];  
  74. }  

小結(jié):iPhone開發(fā)應(yīng)用中ASIFormDataRequest POST操作架構(gòu)設(shè)計的內(nèi)容介紹完了,希望通過本文的學(xué)習(xí)能對你有所幫助!

責(zé)任編輯:zhaolei 來源: 互聯(lián)網(wǎng)
相關(guān)推薦

2011-08-09 09:46:53

iPhoneASIFormData架構(gòu)

2011-08-17 10:24:50

iPhone開發(fā)UIImage圖片

2011-08-22 14:12:48

iPhone開發(fā)NSTableView

2009-07-06 10:36:41

敏捷開發(fā)

2011-08-03 16:01:24

iPhone應(yīng)用開發(fā) 自動登陸

2013-05-27 10:58:28

Tumblr架構(gòu)設(shè)計雅虎收購

2024-10-25 10:48:42

云原生云計算

2010-08-10 10:10:28

系統(tǒng)架構(gòu)

2011-07-26 11:13:15

iPhone PXL

2009-03-18 18:26:32

英特爾Nehalem服務(wù)器

2011-08-08 10:10:14

iPhone開發(fā) 圖片 方法

2011-08-08 16:56:44

iPhone 字符處理 視圖

2011-08-10 10:10:21

iPhoneUIPopoverCo

2011-08-09 17:29:29

iPhone文件屏幕

2011-07-08 14:58:16

iPhone Xcode iOS

2011-07-19 09:46:38

2011-07-19 09:58:36

2015-06-02 04:17:44

架構(gòu)設(shè)計審架構(gòu)設(shè)計說明書

2023-01-05 08:12:11

分層應(yīng)用代碼

2021-01-11 10:19:51

安全架構(gòu)
點贊
收藏

51CTO技術(shù)棧公眾號