I need to save a slider preference in my Settings.bundle.
I’m using the following code to write to the Settings.bundle:
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setInteger:mySlider.value forKey:@"TimerSliderKey"];
[defaults synchronize];
And the following code to read from the Settings.bundle:
NSUserDefaults *defaults2 = [NSUserDefaults standardUserDefaults];
int valueForSlider = [defaults2 integerForKey:@"TimerSliderKey"];
NSLog(@"The saved slider value is %@" , valueForSlider);
This code does not work. Can someone give me some replacement code that I could use?
Your problem is here:
You need to use the
%dformat specifier,%@is the format specifier to send thedescriptionmessage to the argument.Here’s a list of format specifiers:
See the String Programming Guide for more information.