我試圖建立我的NSDictionnary
發送到使用AFNetworking框架的請求,但似乎我很困惑如何正確地做到這一點。AFNetworking - 建立NSDictionary參數
這裏是服務器的期待:
{
"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
}
我試圖做(我真的不知道,如果它這樣做TBH正確的方式),是建立一個的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
我知道我擰ü p正確地構建參數,但是我無法在多次嘗試之後做到這一點。誰能幫忙?此外,我不知道我必須在這裏執行[]
和{}
的區別。我讀{}
是爲字典和[]
爲數組,但我真的不知道如何翻譯它在我的情況。
感謝您的提示!那麼我會嘗試這種方式 – 2012-07-11 14:25:59