Added support to nib2cib for specifying the "Nib Name" property of the View Controller palette to enable view controller initialization from cibs.

This commit is contained in:
Justin Mecham
2009-10-27 20:49:18 -07:00
committed by Ross Boucher
parent 228e801c91
commit 25634a66cb
2 changed files with 16 additions and 8 deletions
+10 -5
View File
@@ -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];
}
+6 -3
View File
@@ -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
{