NSBundle loading a NSViewController

Posted by Staros on Stack Overflow See other posts from Stack Overflow or by Staros
Published on 2010-05-27T14:22:45Z Indexed on 2010/05/27 15:01 UTC
Read the original article Hit count: 492

Filed under:
|
|
|

Hey all,

I'm looking into a project that would upload custom NSBundles that include a NSViewController. In my main program I've got this code to deal with the bundle after it's been loaded...

id principalClass = [loadedBundle principalClass];
id instance = [[principalClass alloc] init];
[localLabel setStringValue:[instance name]];
NSView *incomingView = [[instance viewController] view];
[localView addSubview:incomingView];
[localView display];

And the principal classes init method in the bundle looks like this...

-(id) init {
    if(self = [super init]){
        name = @"My Plugin";
        viewController = [[ViewController alloc] initWithNibName:@"View" bundle:nil];
    }
    return self;
}

View.nib is a nib located in the bundles project. But whenever I load the bundle I get this error...

2010-05-27 09:11:18.423 PluginLoader[45032:a0f] unable to find nib named: View in bundle path: (null) 2010-05-27 09:11:18.424 PluginLoader[45032:a0f] -[NSViewController loadView] could not load the "View" nib.

I know I've got everything wired up because the line [label setStringValue:[instance name]]; sets the label text correctly. Plus, if I take all of the clases in the bundle and load them into my main applications project everything works as expect. Any thoughts on how I can correctly reference "View" in my bundle?

Thanks!

© Stack Overflow or respective owner

Related posts about objective-c

Related posts about cocoa