次のような配列があります。
(
{
id = 4;
name = "AAAA";
},
{
id = 5;
name = "BBBB";
},
{
id = 9;
name = "BBBB";
}
)
id=5 の名前を変更するにはどうすればよいですか?
次のような配列があります。
(
{
id = 4;
name = "AAAA";
},
{
id = 5;
name = "BBBB";
},
{
id = 9;
name = "BBBB";
}
)
id=5 の名前を変更するにはどうすればよいですか?
suppose Array = (
{
id = 4;
name = "AAAA";
},
{
id = 5;
name = "BBBB";
},
{
id = 9;
name = "BBBB";
}
)
//Now to change the name where the id=5
NSMutableDictionary *dict = [array objectAtIndex: 1];
[dict setObject :@"hari kishan" forKey:@"name'];//this will change the name where id = 5
//Or if want to make dynamic
-(void)changeNameForId:(NSString*)id
{
for(NSMutableDictionary *dictionary in array)
{
if([[dictionary objectForKey:@"id" isEqualToString :id]){
[dictionary setObject:@"hari kishan" forKey@"name"]
}
}
}