AFNetworking - NSMutableDictionary 参数

AFNetworking - NSMutableDictionary parameters

我正在尝试构建我的 NSMutableDictionary 以发送到使用 AFNetworking 框架的请求,但我似乎对如何正确执行它感到很困惑。

这是服务器的期望

{
"do":"timeline",
"what":"posting",
"session":"",
"data":{
"status_timeline":"",
    "with_timeline":"",
    "location_timeline":"",
    "category_timeline":"",
    "privacy_timeline":""  
}

我试过这样

NSMutableDictionary *dict = [[NSMutableDictionary alloc]init];
    [dict setValue:@"timeline" forKey:@"do"];
    [dict setValue:@"posting" forKey:@"what"];
    [dict setValue:session forKey:@"session"];
    NSLog(@"Session %@",  [dict  valueForKey:@"session"]);

希望有人能帮帮我谢谢

您可以使用下面的内容来输入您的服务器需要的内容。确保您的服务器将从 dictionary.

中解码 data
  NSMutableDictionary *dicData = [NSMutableDictionary new];
    dicData[@"status_timeline"] = @"";
    dicData[@"with_timeline"] = @"";
    dicData[@"location_timeline"] = @"";
    dicData[@"category_timeline"] = @"";
    dicData[@"privacy_timeline"] = @"";
    NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dicData options:NSJSONWritingPrettyPrinted error:nil];
    NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];


    NSMutableDictionary *dict = [[NSMutableDictionary alloc]init];
    [dict setValue:@"timeline" forKey:@"do"];
    [dict setValue:@"posting" forKey:@"what"];
    [dict setValue:@"" forKey:@"session"];
    [dict setValue:jsonString forKey:@"data"];
    NSLog(@"Your Main Dic: %@",  dict);