Ios 需要在url目标c中发布值数组

Ios 需要在url目标c中发布值数组,ios,objective-c,post,Ios,Objective C,Post,您好,我是开发新手,我需要在url中发布以下数组,请指导我解决此问题 { "order": { "email": "foo@example.com", "fulfillment_status": "fulfilled", "send_receipt": true, "send_fulfillment_receipt": true, "line_items": [ { "variant_id": 447654529,

您好,我是开发新手,我需要在url中发布以下数组,请指导我解决此问题

{
  "order": {
    "email": "foo@example.com",
    "fulfillment_status": "fulfilled",
    "send_receipt": true,
    "send_fulfillment_receipt": true,
    "line_items": [
      {
        "variant_id": 447654529,
        "quantity": 1
      }
    ]
  }
}

是的,在“YourString”中,您可以传递stringit而不是string及其数组。。请看我的问题这是一个json字符串你可以根据上面的json字符串编辑你的答案吗。显示警告“未使用的变量'postDataTask'”
NSURLSessionConfiguration *sessionConfiguration =   [NSURLSessionConfiguration defaultSessionConfiguration];
[sessionConfiguration setAllowsCellularAccess:YES];
[sessionConfiguration setHTTPAdditionalHeaders:@{ @"Accept" : @"application/json" }];

NSURLSession *session = [NSURLSession sessionWithConfiguration:sessionConfiguration];

NSString *datastring = @"{\"order\": {\"email\": \"foo@example.com\",\"fulfillment_status\": \"fulfilled\",\"send_receipt\":true,\"send_fulfillment_receipt\": true,\"line_items\": [{\"variant_id\": 447654529,\"quantity\": 1}]}}";
NSURL  *url = [NSURL URLWithString:[NSString stringWithFormat:@"YOUR LINK"]];
NSLog(@"url=%@",url);

// Configure the Request
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
request.HTTPBody = [datastring dataUsingEncoding:NSUTF8StringEncoding];
request.HTTPMethod = @"POST";

// post the request and handle response
NSURLSessionDataTask *postDataTask = [session dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error)
{
     // Handle the Response
     if(error)
     {
         NSLog(@"%@",[NSString stringWithFormat:@"Please check your internet connection: %@", [error description]]);

         // Update the View
         dispatch_async(dispatch_get_main_queue(), ^{
             // Hide the Loader
             //   [MBProgressHUD hideHUDForView:[[UIApplication sharedApplication] delegate].window animated:YES];                                                          
             [self ShowConnectionError];
         });
         return;
     }
     dispatch_async(dispatch_get_main_queue(), ^{
         NSString *retVal = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
         NSLog(@"retVal=%@",retVal);
     });
}];

// Initiate the Request
[postDataTask resume];