我將如何循環以下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 ";
},
...
我已經試過:
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];
}
不太清楚我是否意味着要創建通過一個NSArray
與內容,然後循環,以增加MyObject
我self.discounts
的NSMutableArray
。
在此先感謝。
你會得到什麼錯誤? – Dani
@Danie:將錯誤添加爲引發錯誤的行旁邊的註釋。 – fuzz
你可以轉儲字典在目標c風格,'NSLog(@「%@」,discountsDict)'併發布它? – Dani