Wednesday, May 1, 2013

NSMutableURLRequest setNetworkServiceType example ios


setNetworkServiceType:

Sets the network service type of the connection.
- (void)setNetworkServiceType:(NSURLRequestNetworkServiceType)networkServiceType
Parameters of [NSMutableURLRequest setNetworkServiceType]
networkServiceType
The network service type.
Example of [NSMutableURLRequest setNetworkServiceType]
[request setNetworkServiceType:NSURLNetworkServiceTypeVoIP];
Example of [NSMutableURLRequest setNetworkServiceType]

  1. NSURL *url = [NSURL URLWithString:@"YOUR URL HERE"];
  2. NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
  3. [request setNetworkServiceType:NSURLNetworkServiceTypeVoIP];
  4. NSURLResponse *response = nil;
  5. NSError *error = nil;
  6. NSData *data = [NSURLConnection sendSynchronousRequest:request
  7. returningResponse:&response
  8. error:&error];