title: Class of View is changing in ViewController?
body: <p>I have a ViewController in my app which has a method that switches between different views od a tabbar. To be able to switch the views in the method the views are loaded in viewDidLoad from their nibs. The switching of the views basically works fine, but just one view always is the wrong one. If I check what could be the problem, I can see in the logs that class of this view changes after it is loaded in viewDidLoad. Generally, there is no mysterious magic if an object changes its class, something must happen. I wonder what might happen after my view is loaded? To be a bit more precise, here is the code that does the "magic":
  The views are loaded in viewDidLoad</p>
  
  <pre><code>- (void)viewDidLoad
  {
      [super viewDidLoad];
      [self setCurrentView:placeholder];
      [self configureView];
      wineryView = [self loadWineryView];
      DLog(@"- %@", [wineryView class]);
      wineView = [self loadWineView];
      DLog(@"- %@", [wineView class]);
      tasteView = [self loadTasteView];
      DLog(@"- %@", [tasteView class]);
  }
  </code></pre>
  
  <p>The log always shows the expected and right class! Afterwards I have the method that changes the views:</p>
  
  <pre><code>- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item
  {
      DLog(@"- %d", item.tag);
      [[self currentView] removeFromSuperview];
  
      switch ([item tag])
      {
          case TAB_WINERY:
              if (self)
              {
                 [self viewWillDisappear:YES];
                 [[self view] addSubview:wineryView];
                 DLog(@"- %@", [wineryView class]);
                 [self setCurrentView:wineryView];
              }
              break;
          case TAB_WINE:
              if (self)
              {
                  [self viewWillDisappear:YES];
                  [[self view] addSubview:wineView];
                  DLog(@"- %@", [wineView class]);
                  [self setCurrentView:wineView];
              }
              break;
          case TAB_TASTE:
              if (self)
              {
                  [self viewWillDisappear:YES];
                  [[self view] addSubview:tasteView];
                  DLog(@"- %@", [tasteView class]);
                  [self setCurrentView:tasteView];
              }
          default:
              break;
          }
      }
  </code></pre>
  
  <p>At that point log doesn't show the expected result! Here is an excerpt of my log:</p>
  
  <pre><code>2013-01-03 10:20:52.032 Weinerei[454:c07] -[DetailViewController viewDidLoad] [Line 51] - WineryView
  2013-01-03 10:20:52.034 Weinerei[454:c07] -[DetailViewController viewDidLoad] [Line 53] - WineView
  2013-01-03 10:20:52.036 Weinerei[454:c07] -[DetailViewController viewDidLoad] [Line 55] - TasteView
  2013-01-03 10:20:58.946 Weinerei[454:c07] -[DetailViewController tabBar:didSelectItem:] [Line 89] - 0
  2013-01-03 10:20:58.948 Weinerei[454:c07] -[DetailViewController tabBar:didSelectItem:] [Line 100] - TasteView
  2013-01-03 10:21:00.378 Weinerei[454:c07] -[DetailViewController tabBar:didSelectItem:] [Line 89] - 1
  2013-01-03 10:21:00.380 Weinerei[454:c07] -[DetailViewController tabBar:didSelectItem:] [Line 109] - WineView
  2013-01-03 10:21:03.306 Weinerei[454:c07] -[DetailViewController tabBar:didSelectItem:] [Line 89] - 2
  2013-01-03 10:21:03.308 Weinerei[454:c07] -[DetailViewController tabBar:didSelectItem:] [Line 119] - TasteView
  </code></pre>
  
  <p>As I don't change the class of the view object anywhere in my code, I do not understand why this happens! Does anyone know what might be a reason for this and how to avoid this?
  Just to show that I don't change the class while loading, here is an example method for loading the view:</p>
  
  <pre><code>- (UIView *) loadTasteView
  {
      NSArray *nibViews = [[NSBundle mainBundle] loadNibNamed:@"TasteView" owner:self options:nil];
      TasteView *tView;
      for (id view in nibViews) {
          if ([view isKindOfClass:[TasteView class]]) 
          {
              tView = (TasteView*) view;
          }
      }
      return tView;
  }
  </code></pre>