【问题标题】:Parameter using JSON to PHP server with AFNetworkingAFNetworking 使用 JSON 到 PHP 服务器的参数
【发布时间】:2013-10-20 04:25:23
【问题描述】:

我想通过 AFNetworking 将使用 JSON 的 NSDictionary 或 NSArray 参数发送到 PHP 服务器

【问题讨论】:

    标签: iphone ios json nsdictionary


    【解决方案1】:
    AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:[NSURL URLWithString:@"https://www.url.com/"]];
    NSDictionary *parameter = @{@"key1":@"value1", @"key2",@"value2"};
    [httpClient setParameterEncoding:AFJSONParameterEncoding];
    [httpClient registerHTTPOperationClass:[AFJSONRequestOperation class]];
    
    [httpClient postPath:@"some/path" parameters:parameter success:^(AFHTTPRequestOperation *operation, id responseObject) {
    
        ....
    
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
    
        ....
    
    }];
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-05
      • 1970-01-01
      • 2015-02-20
      • 1970-01-01
      相关资源
      最近更新 更多