NSViewController loading from nib

This commit is contained in:
Christopher Lloyd 2010-10-21 16:11:11 -04:00
parent 4b8373dca0
commit b7656a9e0e

View File

@ -11,6 +11,18 @@
return self;
}
-initWithCoder:(NSCoder *)coder {
if([coder allowsKeyedCoding]){
_nibName=[[coder decodeObjectForKey:@"NSNibName"] copy];
_title=[[coder decodeObjectForKey:@"NSTitle"] copy];
NSString *bundleIdentifier=[coder decodeObjectForKey:@"NSNibBundleIdentifier"];
if(bundleIdentifier!=nil)
_nibBundle=[NSBundle bundleWithIdentifier:bundleIdentifier];
}
return self;
}
-(NSString *)nibName {
return _nibName;
}
@ -56,6 +68,12 @@
NSString *name=[self nibName];
NSBundle *bundle=[self nibBundle];
if(name==nil){
// should pathForResource assert name for non-nil?
[NSException raise:NSInvalidArgumentException format:@"-[%@ %s] nibName is nil",isa,_cmd];
return;
}
if(bundle==nil)
bundle=[NSBundle mainBundle];