Problem in connecting IBOutlet
<p>In my application, I am trying to remove all existing subviews and add a new one created in Interface Builder. However, I don't seem to be able to connect the view.</p>

<p>When a button clicks, the following function is executed (inside a subclass of UIViewController): </p>

<pre><code>// Display a list of settings to choose from
- (void) settings
{
    SettingsRootController *settingsController = [[SettingsRootController alloc]   initWithNibName:@"SettingsRootController" bundle:nil];
    _settingsController = settingsController;

    for (UIView *view in self.view.subviews) 
    {
        [view removeFromSuperview];
    }

    [self.view addSubview:_settingsController.view2];

    int a = [self.view.subviews count];    
    [self.view setNeedsDisplay];

   ......
}


#import &lt;UIKit/UIKit.h&gt;

@interface SettingsRootController : UIViewController
{
    IBOutlet UIView *_view2;
}

@property(nonatomic, retain) IBOutlet UIView *view2;
</code></pre>

<p>Inside the Interface Builder, I created a new View-based xib. Set file owner to SettingsRootController. Randomly drag a UITextView into the xib. Connect the UITextView to view and view2 in SettingsRootController.</p>

<p>However, if the above line is:</p>

<pre><code>[self.view addSubview:_settingsController.view2];
</code></pre>

<p>a would always be 0, and thus the new screen is empty.</p>

<p>But if change to:</p>

<pre><code>[self.view addSubview:_settingsController.view];
</code></pre>

<p>I could see the UITextView.</p>
