3

I created a framework and added a xib file named "MyXibFile". I created a separate application and added this framework to it. I want to load this .xib file to display the window from it.

I am using the following code snippet which is not working

-(void)launchDownloaderWindow
{
    if (![NSBundle loadNibNamed:@"Download" owner:self]) 
    {
        NSLog(@"Nib loading failed");;
    } 

    [appWindow makeKeyAndOrderFront:nil];
}

I can see the message in the console "Nib loading failed" Any suggestion how to solve this?

Keith Smiley
  • 61,481
  • 12
  • 97
  • 110
Akbar
  • 1,509
  • 1
  • 16
  • 32

1 Answers1

2

I can think of a slightly different way of doing this. In your created framework create a class, possibly an NSWindowController, and have it load and return the window for you. For example after importing the framework you could initialize your window controller and create a strong reference to the window it creates.

WindowController.m

@implementation WindowController

- (id)init {
    self = [super initWithWindowNibName:@"WindowController"];
    ...
    return self;
}

@end

MyApp.m

- (void)showSomeWindow {
    WindowController *wc = [[WindowController alloc] init];
    self.appWindow = wc.window;

    [self.appWindow makeKeyAndOrderFront:self];
}
Keith Smiley
  • 61,481
  • 12
  • 97
  • 110