As Dave Batton said, NSUserDefaults is for defaults on fresh launches of the app. If I understand your question correctly, it appears to me that you are overwriting your default value in firstSliderValueChange. That is why this happens:
the sliders start from where I last had them set the last time I ran the app.
Either store your defaults and in-app values separately or pass them between views.
EDIT:
The code mentioned in your comment below doesn't pass values. It persists values.
Problem: Say you originally have set a slider value default of 0. When you run the app for the first time, you see the slider at 0. Now you move the slider to, say, 5. Then this method is called:
- (IBAction)firstSliderValueChange:(id)sender {
[[NSUserDefaults standardUserDefaults] setFloat:[_firstSlider value] forKey:@"firstSliderValue"];
}
Now the default value is no longer 0. It is 5. And that persists between app launches, since you are using NSUserDefaults.
Solution: Save the dynamic slider value some place else - not in NSUserDefaults. Since you have multiple view controllers, one way is this:
//viewController.m
@interface
@property (strong, nonatomic) IBOutlet UISlider *mySlider;
@end
-(void)prepareForSegue: (UIStoryboardSegue *)segue sender:(id)sender {
if([segue.identifier isEqualToString: @"segueIdentifer"]) {
otherViewController *ovc = (otherViewController *)segue.destinationViewController;
ovc.dynamicSliderValue = self.mySlider.value;
}
}
And:
//otherViewController.h
@interface
@property(assign) CGFloat dynamicSliderValue;
@end
Now, whenever you switch back to your first view controller's view, simply access this property, and update the slider accordingly.
Note - I am sure there are many other ways of doing this!