IPhone application ASIFormDataRequest POST operation Architecture Design

Source: Internet
Author: User

IPhoneApplicationASIFormDataRequestPOST OperationArchitectureDesign is the content to be introduced in this article. It teaches you how to learn about iphone application development.Architecture. Let's talk about the details.

// Enable the iphone network switch

 
 
  1. [UIApplication sharedApplication].networkActivityIndicatorVisible = YES;   
  2. ASIFormDataRequest *request = [[ASIFormDataRequest alloc] initWithURL:[NSURLURLWithString:host]]; 

// Timeout

 
 
  1. request.timeOutSeconds = 30;  

// Define the Asynchronous Method

 
 
  1. [request setDelegate:self];  
  2. [request setDidFailSelector:@selector(requestDidFailed:)];  
  3. [request setDidFinishSelector:@selector(requestDidSuccess:)];  

// User-defined data dictionary type (optional)

 
 
  1. request.userInfo = [NSDictionary dictionaryWithObject:method forKey:@"Method"]; 

// Post Data

 
 
  1. [request appendPostData:[body dataUsingEncoding:NSUTF8StringEncoding]]; 

// Start execution

 
 
  1. [request startAsynchronous]; 

// Execution successful

 
 
  1. - (void)requestDidSuccess:(ASIFormDataRequest *)request  

// Obtain the header file

 
 
  1. NSDictionary *headers = [request responseHeaders];  

// Obtain the http protocol Execution Code

 
 
  1. NSLog(@"Code:%d",[request responseStatusCode]);  
  2. if ([delegaterespondsToSelector:@selector(OARequestSuccessed:withResponse:WithData:withHeaders:)])  

// Select the operating architecture to be delegated)

 
 
  1. [delegate OARequestSuccessed:method withResponse:[request responseString]WithData:[request responseData] withHeaders:headers];  

// Clear

 
 
  1. if (request)  
  2. {  
  3. [request release];  

// Disable the network

 
 
  1. [UIApplication sharedApplication].networkActivityIndicatorVisible = NO;  
  2. }  

// Execution failed

 
 
  1. - (void)requestDidFailed:(ASIFormDataRequest *)request{ 

// Obtain the User-Defined content

 
 
  1. NSString *method = [request.userInfo objectForKey:@"Method"]; 

Summary:IPhoneApplicationASIFormDataRequestPOST OperationArchitectureThe content of the design has been introduced. I hope this article will help you!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.