There are a few ways to do this, you can post a notification that contains an object with the selected information which your opening view subscribes to. You would post this notification at the time that the option was selected in your case.
Another option is to use the delegate pattern, your opening view could be the delegate for your secondary view, when the option is selected a delegate method is called to pass that information back.
What you want to stay away from is providing your secondary view a reference to the opening view, this makes your view hierarchy rigid and your secondary view can no longer be re-used anywhere else without that same opening view.
To delve further into the delegate example which is the route I would take.
Define your ColorPickerViewController
@interface ColorPickerViewController
@property (nonatomic, assign) id delegate;
// other supporting properties
@end
@protocol ColorPickerViewControllerDelegate <NSObject>
@optional
- (void) colorWasPicked:(UIColor *)pickedColor;
@end
@implementation ColorPickerViewController
@synthesize delegate;
- (void)colorSelected { // some method that is called when the user selects a color
if([self.delegate respondsToSelect(@selector(colorWasPicked:)]) {
[self.delegate colorWasPicked:selectedColor];
}
}
@end
And then your opening view controller would instantiate the ColorPickerViewController and assign itself as the delegate
@interface OpeningViewController : UIViewController <ColorPickerViewControllerDelegate> {
}
@implementation OpeningViewController
// implement the delegate method you wrote
- (void) colorWasPicked:(UIColor *)pickedColor {
self.userSelectedColor = pickedColor;
}
Obviously this is not cut and paste code but it should steer you in the right direction, there may be some mistakes but I think for the most part it should be clear.
NSUserDefaultsas an utility to store values that affect application behavior. You should look at @Flash84x's answers for the correct way to go.