Replace a value in NSDictionary in iPhone

前端 未结 5 1360
悲哀的现实
悲哀的现实 2020-12-08 00:31

I have a array (dataArray) of NSDictionary \"item\". It has datas like \"david\" for key \"name\" and \"85\" for key \"marks\" etc for 5 students. I want to replace the mark

5条回答
  •  眼角桃花
    2020-12-08 01:13

    You first need an NSMutableDictionary with it you can change the key and value.

    It would be like this:

    NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithObjectsAndKeys:@"david", @"name", "85", @"marks", nil];
    
    [dict setObject:@"90" forKey:@"david"];
    

提交回复
热议问题