Commits

Anonymous committed 6402f66

Adding -[BWViewController viewDidLoad]

Comments (0)

Files changed (3)

BWTabViewController.m

         [self setView:tabView];
         [self setTabView:tabView];
         [tabView release];
+        
+        [self didCustomLoadView];
     }
 }
 

BWViewController.h

     BWViewController    *_parent;   // weak ref
 }
 
+#pragma mark View
+// Generally override this to do any post-load setup
+- (void)viewDidLoad;
+
+
+#pragma mark Properties
 @property(nonatomic, copy) NSString *identifier;
 @property(nonatomic, assign) BWViewController *parentViewController;
 
+
 @end
 
 
 
 
 @end
+
+
+#pragma mark -
+
+
+@interface BWViewController (SubclassSupport)
+
+// If you override -loadView NOT to call super, then the last thing you do should be to call -didCustomLoadView. This will take care of calling -viewDidLoad in the correct manner. Do NOT call -viewDidLoad directly yourself!
+- (void)didCustomLoadView;
+
+@end
+

BWViewController.m

     [super dealloc];
 }
 
+#pragma mark View
+
+- (void)loadView;
+{
+    [super loadView];
+    [self didCustomLoadView];
+}
+
+- (void)viewDidLoad; { }
+
+- (void)didCustomLoadView;
+{
+    // AppKit may have gotten round to implementing -viewDidLoad. If so, no need to call it ourselves.
+    if (![NSViewController instancesRespondToSelector:@selector(viewDidLoad)])
+    {
+        [self viewDidLoad];
+    }
+}
+
+#pragma mark Properties
+
 @synthesize identifier = _identifier;
 @synthesize parentViewController = _parent;