我想从带有键值对的 for 循环中向 NSMutabledictionary 添加值?
目前正在使用此代码
for(int j=0;j<[array count];j++){
for(int l=0;l<array2 count] ;l++){
// retreive the category from plist ,then check whether its matching with "catid"
NSString *temp=[NSString stringWithFormat:@"%@",allBookPlist[@"listbook"][j][@"cate"][l][@"categories"]];
if([catId isEqualToString:temp]){
// "catid" is matching with temp then ,retreive the corresponding bid from plist
NSString *str=[NSString stringWithFormat:@"%@",allBookPlist[@"listbook"][j][@"bid"]];
// add that value "bid" and key "catid" to a mutabledictionary
NSMutableDictionary *m=[[NSMutableDictionary alloc]init];
[m setValue:str forKey:catId];
}
}
}
结果是每次最终字典“m”的值被最新值替换时,但我希望所有值都在一起?
我试图获得这样的输出