diff --git a/AppKit/CPViewController.j b/AppKit/CPViewController.j index f5a3230d3..64a32d4f9 100644 --- a/AppKit/CPViewController.j +++ b/AppKit/CPViewController.j @@ -66,6 +66,7 @@ var CPViewControllerCachedCibs; { CPView _view @accessors(property=view); BOOL _isLoading; + BOOL _isLazy; id _representedObject @accessors(property=representedObject); CPString _title @accessors(property=title); @@ -124,6 +125,7 @@ var CPViewControllerCachedCibs; _cibExternalNameTable = anExternalNameTable || [CPDictionary dictionaryWithObject:self forKey:CPCibOwner]; _isLoading = NO; + _isLazy = NO; } return self; @@ -139,8 +141,8 @@ var CPViewControllerCachedCibs; implementation for programmatic views is to create a plain view. You can invoke super to utilize this view. - If you use Interface Builder to create your views, you initialize the view - using the initWithCibName:bundle: method then you must not override this + If you use Interface Builder to create your views, and you initialize the view + using the initWithCibName:bundle: method, then you MUST NOT override this method. The consequences risk shattering the space-time continuum. Note: The cib loading system is currently synchronous. @@ -199,6 +201,11 @@ var CPViewControllerCachedCibs; _isLoading = NO; [self viewDidLoad]; } + else if (_isLazy) + { + _isLazy = NO; + [self viewDidLoad]; + } return _view; } @@ -208,9 +215,9 @@ var CPViewControllerCachedCibs; This method is called after the view controller has loaded its associated views into memory. This method is called regardless of whether the views were stored in a nib - file or created programmatically in the loadView method. This method is - most commonly used to perform additional initialization steps on views - that are loaded from cib files. + file or created programmatically in the loadView method, but NOT when setView + is invoked. This method is most commonly used to perform additional initialization + steps on views that are loaded from cib files. */ - (void)viewDidLoad { @@ -228,13 +235,7 @@ var CPViewControllerCachedCibs; */ - (void)setView:(CPView)aView { - var viewWasLoaded = !_view; - _view = aView; - - // Make sure the viewDidLoad method is called if the view is set directly - if (!_isLoading && viewWasLoaded) - [self viewDidLoad]; } @end @@ -266,6 +267,7 @@ var CPViewControllerViewKey = @"CPViewControllerViewKey", _cibBundle = bundlePath ? [CPBundle bundleWithPath:bundlePath] : [CPBundle mainBundle]; _cibExternalNameTable = [CPDictionary dictionaryWithObject:self forKey:CPCibOwner]; + _isLazy = YES; } return self;