I was using a NSMutableArray
and realized that using a dictionary is a lot simpler for what I am trying to achieve.
I want to save a key as a NSSt
Objective-C
Create:
NSDictionary *dictionary = @{@"myKey1": @7, @"myKey2": @5};
Change:
NSMutableDictionary *mutableDictionary = [dictionary mutableCopy]; //Make the dictionary mutable to change/add
mutableDictionary[@"myKey3"] = @3;
The short-hand syntax is called Objective-C Literals
.
Swift
Create:
var dictionary = ["myKey1": 7, "myKey2": 5]
Change:
dictionary["myKey3"] = 3