class="brush:objc;gutter:true;">
以 Get的方式传递Http请求:
NSURL *jsonURL = [NSURL URLWithString:[NSString stringWithFormat:@"http://www.xxx.com/coffeeiphone/Service.svc/maintransactioninsert/%@/%@/%@",stockid,[format stringFromDate:selected],[quantity text], nil]];
NSString *jsonData = [[NSString alloc] initWithContentsOfURL:jsonURL];
以 POST的方式传递Http请求:
NSURL *theUrl = [NSURL URLWithString:@"yourURL"];
NSMutableURLRequest *theRequest = [[NSMutableURLRequest alloc] initWithURL:theUrl];
[theRequest setHTTPMethod:@"POST"];
//set the body of your request:
[theRequest setHTTPBody: //request here];
//get your response:
NSData *response = [NSURLConnection sendSynchronousRequest:theRequest returningResponse:nil error:nil];