From 25634a66cb2d300fa9d96245ff266488486e63a2 Mon Sep 17 00:00:00 2001 From: Justin Mecham Date: Tue, 27 Oct 2009 21:22:00 -0400 Subject: [PATCH] Added support to nib2cib for specifying the "Nib Name" property of the View Controller palette to enable view controller initialization from cibs. --- AppKit/CPViewController.j | 15 ++++++++++----- Tools/nib2cib/NSViewController.j | 9 ++++++--- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/AppKit/CPViewController.j b/AppKit/CPViewController.j index a5493b960..63b3c275b 100644 --- a/AppKit/CPViewController.j +++ b/AppKit/CPViewController.j @@ -166,14 +166,15 @@ var CPViewControllerViewKey = @"CPViewControllerViewKey", - CPViewControllerTitleKey = @"CPViewControllerTitleKey"; + CPViewControllerTitleKey = @"CPViewControllerTitleKey", + CPViewControllerCibNameKey = @"CPViewControllerCibNameKey"; @implementation CPViewController (CPCoding) /*! - Initializes the view item by unarchiving data from a coder. + Initializes the view controller by unarchiving data from a coder. @param aCoder the coder from which the data will be unarchived - @return the initialized collection view item + @return the initialized view controller */ - (id)initWithCoder:(CPCoder)aCoder { @@ -183,19 +184,23 @@ var CPViewControllerViewKey = @"CPViewControllerViewKey", { _view = [aCoder decodeObjectForKey:CPViewControllerViewKey]; _title = [aCoder decodeObjectForKey:CPViewControllerTitleKey]; + _cibName = [aCoder decodeObjectForKey:CPViewControllerCibNameKey]; + _cibBundle = [CPBundle mainBundle]; + _cibExternalNameTable = [CPDictionary dictionaryWithObject:self forKey:CPCibOwner]; } return self; } /*! - Archives the colletion view item to the provided coder. - @param aCoder the coder to which the view item should be archived + Archives the view controller to the provided coder. + @param aCoder the coder to which the view controller should be archived */ - (void)encodeWithCoder:(CPCoder)aCoder { [super encodeWithCoder:aCoder]; + [aCoder encodeObject:_cibName forKey:CPViewControllerCibNameKey]; [aCoder encodeObject:_view forKey:CPViewControllerViewKey]; [aCoder encodeObject:_title forKey:CPViewControllerTitleKey]; } diff --git a/Tools/nib2cib/NSViewController.j b/Tools/nib2cib/NSViewController.j index 58d8fada3..9dc3ea5ac 100644 --- a/Tools/nib2cib/NSViewController.j +++ b/Tools/nib2cib/NSViewController.j @@ -27,14 +27,17 @@ - (id)NS_initWithCoder:(CPCoder)aCoder { - return [super NS_initWithCoder:aCoder]; + self = [super NS_initWithCoder:aCoder]; + + if (self) + _cibName = [aCoder decodeObjectForKey:@"NSNibName"]; + + return self; } @end @implementation NSViewController : CPViewController -{ -} - (id)initWithCoder:(CPCoder)aCoder {