1. mikeabdullah
  2. BWToolkit

Commits

Mike Abdullah  committed 89e6d43

BWTabViewController sets itself as the parent of its view controllers

  • Participants
  • Parent commits c09c8ef
  • Branches default

Comments (0)

Files changed (1)

File BWTabViewController.m

View file
 
 - (void)dealloc
 {
+    // Detach controllers first
+    [[self viewControllers] makeObjectsPerformSelector:@selector(setParentViewController:)
+                                            withObject:nil];
+    
+    // Tear down views
     [self setTabView:nil];  // releases view and tears down binding/delegation
     
+    // Release ivars
     [_tabViewItems release];
     [_viewControllers release];
     
     // Store controller
     NSUInteger oldCount = [self countOfViewControllers];
     [_viewControllers insertObject:controller atIndex:index];
+    [controller setParentViewController:self];
     
      
     // Store corresponding NSTabViewItem
 - (void)removeViewController:(NSViewController *)controller;
 {
     // Remove controller
+    [controller setParentViewController:nil];
     NSUInteger index = [_viewControllers indexOfObject:controller];
     [_viewControllers removeObjectAtIndex:index];