This question already has an answer here:
-
*
/questions/7819092/how-can-i-add-properties-to-an-object-at-runtime
/questions/7819092/how-can-i-add-properties-to-an-object-at-runtime
3 answers
Answers
Just declare it as a property.
@property (nonatomic, strong) NSDictionary * dic;
or
@property (nonatomic, strong) NSMutableDictionary * dic;
And then later at runtime create it the way you want.
self.dic = @{randomKey : randomValue};
or
self.dic = [@{randomKey : randomValue} mutableCopy];
Source
License : cc by-sa 3.0
http://stackoverflow.com/questions/17808261/how-can-i-add-dynamically-properties-to-an-object-at-runtime-in-objective-c