As far as I understand, you do not need a mutable array, but you need to convert NS dictionaries inside your array into a variable. Others also respond to this.
But I want to show a great trick how you can set up adding a key / value pair to all mutable dictionaries online. I use much simpler data, since itβs easier for you to see what is happening.
//just an example array of mutable Dictionary NSMutableArray *array = [NSMutableArray array]; [array addObject:[NSMutableDictionary dictionaryWithObject:@"one" forKey:@(1)]]; [array addObject:[NSMutableDictionary dictionaryWithObject:@"two" forKey:@(2)]]; [array addObject:[NSMutableDictionary dictionaryWithObject:@"three" forKey:@(3)]]; // and here is the trick [array setValue:@"10" forKey:@"tag"];
The array now contains
( { tag = 10; 1 = one; }, { tag = 10; 2 = two; }, { 3 = three; tag = 10; } )
from NSArray docs
setValue:forKey:
Calls setValue: forKey: for each element of the array using the specified value and key.
- (void)setValue:(id)value forKey:(NSString *)key
vikingosegundo
source share