title: Loading a UIViewController with a nib result with a nil view property
body: <p>So I've got a few UIViewControllers which I've subclassed that I'm trying to instantiate with nib files as views. The problem is that once I instantiate them, the view property on them is throwing an <code>EXC_BAD_ACCESS</code> error and crash the app goes.</p>
  
  <p>Here's what I'm doing:</p>
  
  <h3>KMLFTPConnectionEditViewController.h</h3>
  
  <pre><code>#import &lt;UIKit/UIKit.h&gt;
  @interface KMLFTPConnectionEditViewController : UIViewController
  @end
  </code></pre>
  
  <h3>KMLFTPConnectionEditViewController.m</h3>
  
  <pre><code>#import "KMLFTPConnectionEditViewController.h"
  
  @interface KMLFTPConnectionEditViewController ()
  
  @end
  
  @implementation KMLFTPConnectionEditViewController
  
  - (id)init
  {
      self = [super initWithNibName:@"KMLFTPConnectionEditView" bundle:nil];
      if ( self ) {
      }
      return self;
  }
  
  - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
  {
      return [self init];
  }
  
  - (void)viewDidLoad
  {
      [super viewDidLoad];
  }
  
  @end
  </code></pre>
  
  <h3>Elsewhere</h3>
  
  <pre><code>KMLFTPConnectionEditViewController * ftpvc = [[KMLFTPConnectionEditViewController alloc] init];
  NSLog(@"View: %@", ftpvc.view); // &lt;- crash!
  </code></pre>
  
  <p>Now, as for the nib, it's called <code>KMLFTPConnectionEditView.xib</code>, and it meets all the requirements I think it needs, as far as I can tell from other SO posts, as well as Apple's own docs:</p>
  
  <ol>
  <li>Its file's owner class is set to <code>KMLFTPConnectionEditViewController</code></li>
  <li>Its file's owner's view outlet is connected to the primary view in the nib.</li>
  <li>The nib exists in the project, and it's included in the main application bundle.</li>
  </ol>
  
  <p>This is the also the case with another UIViewController subclass I set up with a nib.</p>
  
  <p>This was working for me this morning, but I must have made a change (there was an XCode update today...) which I'm just not seeing. I've been battling this for hours, to no avail.</p>
  
  <p>Is there something simple I'm overlooking here?</p>
  
  <h3>UPDATE 1</h3>
  
  <p>It's too big to post inline here, but as per Aaron's request below, <a href="https://dl.dropboxusercontent.com/u/479690/picuploader-crashlog.txt" rel="nofollow">here is the crash log</a>. It looks like something is recursing with the UITextField appearance proxy I've set up. Any ideas?</p>
  
  <h3>UPDATE 2</h3>
  
  <p>If I remove the UITextFields from the nib that I'm trying to load up, there's no problem. Once I put any UITextInput views back in the nib, even if they're not hooked up to any outlets or set up in any way, then I get this recursion crash.</p>
  
  <p>Since it seems to be something going on with the appearance proxy and the UITextField, here's the method I've got set up in the AppDelegate to define appearances. Note that any non-standard colors have been defined in a UIColor+AppStyles category, which is imported into the AppDelegate.</p>
  
  <pre><code>- (void)customizeAppearance
  {
      // Customize the navigation bar appearance
      UIImage *navbarBackgroundImage = [[UIImage imageNamed:@"background-navbar.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0)];
      [[UINavigationBar appearance] setBackgroundImage:navbarBackgroundImage forBarMetrics:UIBarMetricsDefault];
      [[UINavigationBar appearance] setTitleTextAttributes:
           [NSDictionary dictionaryWithObjectsAndKeys:
                [UIColor primaryTextColor], UITextAttributeTextColor,
                [UIColor primaryTextShadowColor], UITextAttributeTextShadowColor,
                [NSValue valueWithUIOffset:UIOffsetMake(0, -1)], UITextAttributeTextShadowOffset,
                [UIFont titleHeaderFont], UITextAttributeFont,
                nil
            ]
       ];
      [[UINavigationBar appearance] setTitleVerticalPositionAdjustment:1 forBarMetrics:UIBarMetricsDefault];
  
      // And the toolbar buttons
      UIOffset buttonTextOffset = UIOffsetMake(0, 2);
      UIImage *navbarButtonImage = [[UIImage imageNamed:@"background-navbar-button"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 2, 0, 2)];
      UIImage *navbarBackButton = [[UIImage imageNamed:@"background-navbar-back-button"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 15, 0, 2)];
      NSDictionary *buttonTextAttributes = [NSDictionary dictionaryWithObjectsAndKeys:
                                              [UIColor invertedTextColor], UITextAttributeTextColor,
                                              [UIColor invertedTextShadowColor], UITextAttributeTextShadowColor,
                                              [NSValue valueWithUIOffset:UIOffsetMake(0, 1)], UITextAttributeTextShadowOffset,
                                              [UIFont buttonFontSmall], UITextAttributeFont,
                                              nil
                                            ];
  
      // Text styles
      [[UIBarButtonItem appearance] setTitleTextAttributes:buttonTextAttributes forState:UIControlStateNormal];
  
      // Normal bar buttons
      [[UIBarButtonItem appearance] setBackgroundImage:navbarButtonImage forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
      [[UIBarButtonItem appearance] setTitlePositionAdjustment:buttonTextOffset forBarMetrics:UIBarMetricsDefault];
  
      // Back button
      [[UIBarButtonItem appearance] setBackButtonBackgroundImage:navbarBackButton forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
      [[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:buttonTextOffset forBarMetrics:UIBarMetricsDefault];
  
      // And now for the tab bar
      UIImage *toolbarBackgroundImage = [[UIImage imageNamed:@"background-toolbar.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0)];
      [[UIToolbar appearance] setBackgroundImage:toolbarBackgroundImage forToolbarPosition:UIToolbarPositionBottom barMetrics:UIBarMetricsDefault];
  
      // Text Inputs  
      [[UITextField appearance] setBorderStyle:UITextBorderStyleNone];
      [[UITextField appearance] setBackgroundColor:[UIColor clearColor]];
      [[UITextField appearance] setFont:[UIFont textInputFont]];
      [[UITextField appearance] setTextColor:[UIColor invertedTextColor]];
      [[UITextField appearance] setTextAlignment:NSTextAlignmentRight];
  
      // And labels
      [[UILabel appearance] setFont:[UIFont formLabelFont]];
      [[UILabel appearance] setTextColor:[UIColor invertedTextColor]];
  
      [[KMLSectionHeaderLabel appearance] setFont:[UIFont titleHeaderFont]];
      [[KMLSectionHeaderLabel appearance] setBackgroundColor:[UIColor sectionHeaderBackgroundColor]];
  }
  </code></pre>
  
  <h3>UPDATE 3</h3>
  
  <p>So I've narrowed it down to one line of code in the appearance proxy method that is causing the crash:</p>
  
  <pre><code>[[UITextField appearance] setBackgroundColor:[UIColor clearColor]];
  </code></pre>
  
  <p>If I comment that out, all is well. It seems I don't even need that for what I want to do, but any ideas as to why that would be causing the recursion and crash? And more puzzlingly, why was this working just fine yesterday morning? I hadn't made any changes to that part of the appearance proxy code (I had tweaked the <code>UILabel</code> bits and added the <code>KMLSectionHeaderLabel</code> bits, though). I'd like to understand what's going on here.</p>