I want to add all the keys from the dictionary to the array. This is what I am doing right now.As code below:
for (NSString * akey in _groups ) {
NSLog(@"%@",akey);
[_groupArray addObject:akey];
NSLog(@"%@",_groupArray);
}
The log is showing Null for _groupArray. I even tried using insertObjectAtIndex even that does not work.Not sure what I am doing wrong and yes I am getting the keys in the dictionary (_groups) nothing wrong with that.
You should initialize the array before starting to add values to it. Otherwise it is initially
niland will remainnil.You can use
allKeysto get all the keys of the array. But since_groupArrayis anNSMutableArray, you have to do that like this:Or: