I have a multiuser application and an array of dictionary for keeping information of each user. Each dictionary contains info of one user. For example I have following keys in per user Dictionaries.
userId
settingsWithin settings I have another Dictionary with keysmusicVolumeandlanguage
I use these keys with the following code
[settingsInfo setValue:[NSNumber numberWithInt:0] forKey:@"musicVolume"];
Now these keysName strings like @"musicVolume" were getting spread all over my code. So I decided to make a singleton UtilityClass that i could use to fetch the strings. Now code looks like
UtilityClass* shared = [UtilityClass sharedInstance]
[settingsInfo setValue:[NSNumber numberWithInt:0] forKey:shared.musicVolume];
but what I want to do is i.e. music volume with a different keyPath
[settingsInfo setValue:[NSNumber numberWithInt:0] forKey:shared.settings.musicVolume];
One way i could do it is by creating a struct or a class for settings and then keeping musicVolume with in it. But I was wondering if there is way to do it without creating the class or strict. Directly creating a variable with our own keyPath.
You can opt for const, #define, enum. But the best way in Dictionary that you are using.