没有 MainMenu.xib 的 Cocoa 应用程序
对于 iOS (Cocoa Touch),可以转到 main.m 并将 UIApplicationMain(int argc, char *argv[], nil, nil) 中的第四个参数替换为您的类名应用程序的委托,然后根据需要构建视图。然而,Cocoa (Mac) 项目在 main.m 中有以下内容:
return NSApplicationMain(argc, (const char **)argv);
所以问题基本上是:如何将应用程序的委托移交给没有 MainMenu.xib 的 Cocoa 应用程序?
For iOS (Cocoa Touch), it's possible to go to your main.m and replace the fourth argument in UIApplicationMain(int argc, char *argv[], nil, nil)
with the class name of your app's delegate, which would then construct the views as needed. However, Cocoa (Mac) projects have the following in main.m:
return NSApplicationMain(argc, (const char **)argv);
So the question is basically: how do you hand over an app's delegate to Cocoa apps without a MainMenu.xib?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用
NSApplication
实例的setDelegate
方法。这是一个示例:至于返回值,您可以使用
EXIT_SUCCESS
You can use
setDelegate
method ofNSApplication
instance. Here is a sample:As for return value you can use
EXIT_SUCCESS
子类
NSApplication
,将子类的名称声明为 Xcode 中的Application Class
(或类似)属性。在您的子类中,您可以覆盖应用程序初始化时调用的一些函数,也许是-finishLaunching
?Subclass
NSApplication
, declare your subclass's name as theApplication Class
(or similar) property in Xcode. In your subclass you may override some function that gets called when the app is initialized, maybe-finishLaunching
?