NSMutableDictionary *expense_ArrContents = [[NSMutableDictionary alloc]init];
for (int i = 1; i<=4; i++) {
NSMutableArray *current_row = [NSMutableArray arrayWithObjects:@"payer_id",@"Expense_Type_id",@"Category_Id",@"SubCategory_Id",nil];
[expense_ArrContents setObject:current_row forKey: [NSNumber numberWithInt:i]];
}
NSArray *newArray = [expense_ArrContents allKeysForObject:@"payer_id"];
NSLog(@"%@",[newArray description]);
i want to get the list of key values containing the particular object which is in the array of values stored in nsmutabledictionary for a particular key.
In the line where you get all the keys (
[expense_ArrContents allKeysForObject:@"payer_id"];) you actually get keys for an object that is not in any of the array’s items. This@"player_id"is different object than the@"player_id"you added incurrent_row. In fact, maybe all of your rows have different@"player_id"objects (except if the compiler has made some optimization – maybe it threats that same string literal as one object instead of creating new object for each iteration).Try creating an NSString object for the
@"player_id"which you add to thecurrent_rowand then get all the keys for that same object: