次のループをどのようにしてループしますかNSDictionary
?NSDictionaryをループしてNSMutableArrayに追加する
2011-10-27 11:40:23.775 Discounts[305:f803] {
NewDataSet = {
Discounts = (
{
BIN = {
text = "\n 900020";
};
DiscountId = {
text = "\n \n d06dab1b-a2a3-464e-a522-00185fcf5e7c";
};
DiscountPrice = {
text = "\n 75%";
};
GRP = {
text = "\n 8013230";
};
PCN = {
text = "\n CLAIMNE";
};
Title = {
text = "\n duralclon";
};
UID = {
text = "\n 100000";
};
text = "\n ";
},
{
BIN = {
text = "\n 900020";
};
DiscountId = {
text = "\n \n 159d9ba9-462c-47a2-a23e-002137c6fd2e";
};
DiscountPrice = {
text = "\n 75%";
};
GRP = {
text = "\n 8013230";
};
PCN = {
text = "\n CLAIMNE";
};
Title = {
text = "\n allermax";
};
UID = {
text = "\n 100001";
};
text = "\n ";
},
...
私が試した:私は私のNSMutableArray
self.discounts
のにMyObject
を追加するために、それによって内容でNSArray
して、ループを作成するためのものだかどうか
for (id key in discountsDict) {
MyObject *obj = [[MyObject alloc] init];
obj.Title = (NSString *)[key objectForKey:@"Title"]; // *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<__NSCFString 0x6ca2eb0> valueForUndefinedKey:]: this class is not key value coding-compliant for the key Title.'
[self.discounts addObject:obj];
[obj release];
}
かなりわかりません。
ありがとうございます。
どのようなエラーが表示されますか? – Dani
@ダニー:エラーをスローする行の隣にコメントとしてエラーを追加しました。 – fuzz
辞書を目的のCスタイルの 'NSLog(@"%@ "、discountsDict)'にダンプして投稿できますか? – Dani