title: Set delegate object for custom class
body: <p>I made a custom view.<br>
  I set two starting methods,<br>
  1. initWithFrame (for code initialization)<br>
  2. initWithCoder (for storyboard initialization)</p>
  
  <p>In my custom class</p>
  
  <pre><code>- (id)initWithFrame:(CGRect)frame
  {
      self = [super initWithFrame:frame];
      if (self) {
          // [self setUp] method contain the code to run the delegate.
          [self setUp];
      }
      return self;
  }
  
  - (id)initWithCoder:(NSCoder *)aDecoder
  {
      self = [super initWithCoder:aDecoder];
      if (self) {
          // [self setUp] method contain the code to run the delegate.
          [self setUp];
          self.backgroundColor = [UIColor greenColor];
      }
      return self;
  }
  </code></pre>
  
  <p>Then, I add a View to storyboard and change the class at identity inspector.
  I connect the view to the viewcontroller property.</p>
  
  <p>I set the delegate and data source</p>
  
  <p>In my view controller</p>
  
  <pre><code>@interface ViewController () &lt;UIControlViewDataSource, UIControlViewDelegate&gt;
  
  @property (weak, nonatomic) IBOutlet UIControlView *controlView;
  
  @end
  
  - (void)viewDidLoad
  {
      self.controlView.delegate = self;
      self.controlView.dataSource = self;
  }
  </code></pre>
  
  <p>The initWithCoder is running before viewDidLoad,</p>
  
  <p>Because of it the delegate will never run because the initWithCoder in my custom class is running before I set the delegate in viewDidLoad in my view controller.<br>
  And the delegate property will have NULL value.</p>
  
  <p>How could I set the delegate?</p>