I’m looking to storing multiple instances of UIControlState within NSUserDefaults on the IOS platform.
Let’s say there is a preference panel with various UIControl elements, be they UISlider, UISwitch etc.
Currently I have a loadPrefs function within viewWillAppear and a corresponding writePrefs within viewWillDisappear.
Rather than adding the code to store the state within NSUserDefaults for any future control that I add, is there an easy way to iterate through all the keys in NSUserDefaults and set the relevant states accordingly?
Is there a “proper” way of doing this via an NSArray or some other collection or is it not worth the time and bother?
You can get the entire NSUserDefaults stuff as an NSDictionary by using the dictionaryRepresentation method:
Hope this helps.