NSApplication和-applicationDidFinishLaunching: [英] NSApplication and -applicationDidFinishLaunching:

查看:452
本文介绍了NSApplication和-applicationDidFinishLaunching:的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序,其中我有一个 main.m 返回 NSApplicationMain(argc,(const char **)argv) code>。

I have an application where I have a main.m that returns NSApplicationMain(argc, (const char **) argv);.

我想在 -applicationDidFinishLaunching:上运行代码,去做吧。

I want to run code on -applicationDidFinishLaunching:, but I just dont see how to do it.

任何人都可以帮助或举个例子吗?

Can anyone help or have an example?

谢谢!
-Jason

Thanks! -Jason

推荐答案

应用程序完成加载后,将调用NSApplication委托的applicationDidFinishLaunching:方法。许多项目模板设置了一个委托。如果你正在使用一个只是添加适当的方法到它。

The applicationDidFinishLaunching: method of the NSApplication delegate will be called when the app has finished loading. Many of the project templates setup a delegate. If you are using one just add the appropriate method to it.

如果你的项目没有设置应用程序,你需要自己做。首先,使一个新类作为你的委托(你可以使用一个逻辑上合适的事物)。现在确保该类在MainMenu.nib中实例化。最后,将File's Owner对象的delegate属性挂钩到IB中的实例化委托。

If your project does not have an app delegate set up you will need to do that yourself. First, make a new class to act as your delegate (you can use an exiting one if there is something logically appropriate). Now make sure that class is instantiated in your MainMenu.nib. Finally, hook the delegate property of the "File's Owner" object to the instantiate delegate in IB.

这篇关于NSApplication和-applicationDidFinishLaunching:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆