私のプロジェクトでは、PHPを使用して独自のAPIを構築しました。 JSONエンコーディングの結果は基本的に私がObjective-CでJSONを解析する
{"terms":[
{"term0":
{"content":"test id",
"userid":"100","translateto":null,
"hastranslation":"0",
"created":"2011-10-19 16:54:57",
"updated":"2011-10-19 16:55:58"}
},
{"term1":
{"content":"Initial content",
"userid":"3","translateto":null,
"hastranslation":"0",
"created":"2011-10-19 16:51:33",
"updated":"2011-10-19 16:51:33"
}
}
]
}
の下に、私はNSMutableDictionaryでの作業問題を抱えてきたとObjective-Cの「コンテンツ」を抽出するようなエントリの配列を与えます。私はログに係る__NSArrayMあるresponseDataDictにobjectForKey送信する場合のNSLogがエラーを吐き出す
- (void) connectionDidFinishLoading:(NSURLConnection *)connection {
[connection release];
NSString *responseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
[responseData release];
NSMutableDictionary *JSONval = [responseString JSONValue];
[responseString release];
if (JSONval != nil) {
NSMutableDictionary *responseDataDict = [JSONval objectForKey:@"terms"];
if (responseDataDict!= nil) {
for (id key in responseDataDict) {
NSString *content = [[responseDataDict objectForKey:key]objectForKey:@"content"];
[terms addObject:content];
textView.text = [textView.text stringByAppendingFormat:@"\n%@", content];
}
button.enabled = YES;
}
}
}
。
私はここで何が間違っていましたか?
使用しているJSONパーサーが可変コレクションを返すのですか? –