title: How to programmatically set UISlider initial value, or, how does an iOS program start up?
body: <p>I have been developing in xCode for exactly 3 days now.  The last time I did UI development it was in Windows 3.1 with the Petzold book.  Regardless of that I have my first iOS app up and running and it basically does what I need.  I have two sliders to select hue and saturation, and in response to them I dynamically draw a bunch of gradient shaded circles.  I got that much running between the Hello World example and stackoverflow, including caching the gradient in CGLayer (so thanks to all the stackoverflow people).  There is one little piece that I can't quite get right though:</p>
  
  <p>I want to set the initial value of one slider to 1.0 instead of the default 0.5.  I know I can do that in IB, but I prefer to code it and I think I'd like to move away from IB altogether.  I don't really understand how it makes connections between things and I'd like to understand the code.  I have code like this to try to set it:</p>
  
  <pre><code>- (void)viewDidLoad
  {
      NSLog(@"viewDidLoad");
      [super viewDidLoad];
      [hue_slider setValue:0.5];
      [sat_slider setValue:1.0];
      self.led_view.hue_slider_value=0.5;
      self.led_view.sat_slider_value=1.0;
  // Do any additional setup after loading the view, typically from a nib.
  }
  </code></pre>
  
  <p>sat_slider still ends up in the middle instead of at the end (1.0 is the max value).  From stackexchange reading I understand that I am probably calling this at the wrong time, that the slider hasn't really been loaded when viewDidLoad is called, and my initial value is overwritten by the one specified in IB.  What I haven't seen though is where the call should be made.  So the question:</p>
  
  <p>Where in my program should I put </p>
  
  <pre><code>[sat_slider setValue:1.0];
  </code></pre>
  
  <p>so that it sets the initial value of the slider, overwriting the default in IB?  Can someone explain the order of how things start up in an iOS program?  And a pointer to online or printed books regarding iOS and Objective C programming would be great.</p>
  
  <p><strong>Edit</strong></p>
  
  <p>When I check the value of sat_slider it is nil. So that means a connection is missing? I dragged it in the storyboard and created an IBOutlet in addition to an action.</p>
  
  <pre><code>@interface led_testViewController : UIViewController
  
  - (IBAction)saturation_scroll:(id)sender;
  - (IBAction)hue_scroll:(id)sender;
  
  @property (retain, nonatomic) IBOutlet UISlider *hue_slider;
  @property (retain, nonatomic) IBOutlet UISlider *sat_slider;
  @property (strong, nonatomic) IBOutlet led_view *led_view;
  
  @end
  </code></pre>