在Xcode中使用Cocoa框架显示窗口

Che*_*tan 6 xcode cocoa frameworks objective-c

我在Xcode中构建一个框架,我需要在调用函数时显示一个窗口.如何让我的框架显示我在Interface Builder中构建的窗口?一步一步的说明将不胜感激!

谢谢,Chetan

Ken*_*agh 8

你这样称呼它:

    MyWindowController* controller = [[MyWindowController alloc] 
     initWithWindowNibName:@"Foo"];
    [controller showWindow:nil];
Run Code Online (Sandbox Code Playgroud)

其中Foo是nib文件的名称,并且MyWindowController是NSWindowController的子类,您将其设置为nib文件的所有者.

在这种情况下,继承NSWindowController很重要,因为它会自动搜索该类所在的bundle中的nib文件.