我想發送NSDictionary
數據與AFNetworking
POST
方法並從服務器獲取結果。 這是我NSDictionary
:POST方法AFNetworking響應未完成
{
"category_id" = "-1";
"city_id" = "-1";
"degree_id" = "-1";
"experience_id" = "-1";
industries = (
{
id = 2;
},
{
id = 4;
},
{
id = 3;
}
);
"position_id" = "-1";
"salary_id" = "-1";
skills = (
{
aa = id;
},
{
aa = asdasda;
}
);
"type_id" = "-1";
}
時將這個NSDictionary中我的服務器收到我的數據是這樣的:
{
"category_id" = "-1";
"city_id" = "-1";
"degree_id" = "-1";
"experience_id" = "-1";
industries = (
2,
4,
3
);
"position_id" = "-1";
"salary_id" = "-1";
skills = (
id,
asdasda
);
"type_id" = "-1";
}
我從這個如此混亂!
行業&技能是在我的NSDictionary字典數組,但是當服務器接收不顯示密鑰,只顯示數組值!
請指導我。
這是我POST
方法:
self.params = [[NSMutableDictionary alloc]init];
[self.params setObject:[NSNumber numberWithInteger:[self.object.jobCategory integerValue]] forKey:@"category_id"];
[self.params setObject:[NSNumber numberWithInteger:[self.object.jobCity integerValue]] forKey:@"city_id"];
[self.params setObject:self.object.industry forKey:@"industries"];
[self.params setObject:[NSNumber numberWithInteger:[self.object.educationDegree integerValue]] forKey:@"degree_id"];
[self.params setObject:[NSNumber numberWithInteger:[self.object.experience integerValue]] forKey:@"experience_id"];
[self.params setObject:[NSNumber numberWithInteger:[self.object.jobType integerValue]] forKey:@"type_id"];
[self.params setObject:[NSNumber numberWithInteger:[self.object.jobSalary integerValue]] forKey:@"salary_id"];
[self.params setObject:[NSNumber numberWithInteger:[self.object.jobPosition integerValue]] forKey:@"position_id"];
[self.params setObject:[NSMutableArray array] forKey:@"skills"];
[[self.params objectForKey:@"skills"] addObject:[NSMutableDictionary dictionaryWithObjectsAndKeys:@"id",@"aa", nil]];
[[self.params objectForKey:@"skills"] addObject:[NSMutableDictionary dictionaryWithObjectsAndKeys:@"asdasda",@"aa", nil]];
//NSData *jsonData = [NSJSONSerialization dataWithJSONObject:self.params options:NSJSONWritingPrettyPrinted error:nil];
//NSString *str = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
NSLog(@"%@",self.params);
NSString* path = [NSString stringWithFormat:@"%@%@" , [PublicMethods getStrings:@"url"],[PublicMethods getStrings:@"searchJob"]];
[self.network callPOSTWebServiceWithPath:path AndWithParameters:self.params withCallback:^(NSDictionary *result)
{
NSLog(@"%@",result);
if ([[result objectForKey:@"result"]boolValue])
{
NSLog(@"%@",[result objectForKey:@"data"]);
}
else
{
//error accured
}
}];
你顯示的第二個日誌是'self.params'?你是否記錄了'self.object.industry'來檢查它是否正確?什麼是日誌'[self.params objectForKey:@「skills」]'?我看不出有什麼問題。 – Larme
@Larme我的朋友,當我登錄[self.params objectForKey:@ 「技能」]顯示我:技能=( { AA = ID; },{ AA = asdasda; } ) – kasiri182