NSBundle loads NSViewController

I am looking at a project that will load custom NSBundles that include NSViewController. In my main program, I have this code to work with the package after downloading it ...

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 init method of the main classes 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 the nib located in the bundles project. But whenever I download a package, I get this error ...

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

, , [label setStringValue:[instance name]]; . , , , . , "" ?

!

+3
2

init nil bundle. UIViewController, nil NIB ( ), , .

, :

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

:

Class principalClass = [loadedBundle principalClass];
id instance = [[principalClass alloc] initWithBundle:loadedBundle];
+2

"View.xib - "? xib, . Xib . xib , nib. , ibtool. Xcode xib , ibtool, nib, "".

0

Source: https://habr.com/ru/post/1747379/


All Articles