AFNetworking和阵列发布

时间:2014-12-03 23:05:20

标签: ios objective-c afnetworking

我正在尝试将一组字符串发布到我的服务器:

NSMutableArray *test = [[NSMutableArray alloc] init];
for(Contact *x in numbers){
    [test addObject:x.number];
}


NSDictionary *params = [[NSDictionary alloc] init];
params = @{@"token" : v1_Token,
           @"numbers" : test
          };

AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
manager.requestSerializer = [AFJSONRequestSerializer serializer];
manager.responseSerializer = [AFJSONResponseSerializer serializer];
[manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];

@try{
     NSString *url = API_URL;
     url =[url stringByAppendingString:@"retrieve"];
     [manager POST:url parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {

        NSLog(responseObject);

      } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
              NSLog(@"%@",[error localizedDescription]);
      }];
}
@catch(NSException * e){
    //error
}

x.numbers输出字符串变量

我的原始帖子数据应如下所示:

{
"token": "0r1x0002W53Nk1zD889868P1QJ11Us88",
"numbers": ["5555555555","9055550000"]
}

问题是我似乎无法让它显示出来。

0 个答案:

没有答案