我正在尝试NSDictionnary
使用 AFNetworking 框架构建我的发送到请求,但似乎我对如何正确执行它感到很困惑。
这是服务器所期望的:
{
"limit":10,
"filters":
[
{"field":"owner","operator":"EQUAL","value":"ownerId","type":"integer"},
{"field":"date","operator":"GE","value":"30 Jun 2010 00:00:00","type":"date"},
],
"order":[{"field":"date","order":"ASC"}],
"page":0
}
我正在尝试做的(我真的不知道这是否是正确的方法),是构建一个如下所示的 NSDictionary:
NSDictionary *parameters = [NSDictionary dictionaryWithObjectsAndKeys:
@"10", @"chunkSize",
[NSDictionary dictionaryWithObjectsAndKeys:
[NSDictionary dictionaryWithObjectsAndKeys:@"owner", @"field", @"EQUAL", @"operator", @"ownerId", @"value", @"integer", @"type", nil],
[NSDictionary dictionaryWithObjectsAndKeys:@"date", @"field", @"GE", @"operator", @"30 Jun 2010 00:00:00", @"value", @"date", @"type", nil],
nil], @"filters",
[NSDictionary dictionaryWithObjectsAndKeys:
[NSDictionary dictionaryWithObjectsAndKeys:@"date", @"field", @"ASC", @"order", nil],
nil], @"order",
@"0", @"page",
nil];
但是在加载视图时出现以下错误:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException',
reason: '+[NSDictionary dictionaryWithObjectsAndKeys:]: second object of each pair must be non-nil
我知道我正确地构建了参数,但经过几次尝试后我无法做到。有人可以帮忙吗?此外,我真的不知道我必须在这里与[]
和实现的区别{}
。我读到这{}
是一本字典和[]
一个数组,但我真的不知道如何翻译它。