提供OSX服务而不启动应用程序

提供OSX服务而不启动应用程序

本文介绍了提供OSX服务而不启动应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已成功实施了匿名服务(仅限后台应用,扩展名为.service),并使其正常工作(请参见),基于和其他网络教程。



现在,我想从一个现有的,窗口GUI应用程序。



我设置了我的应用程序的Info.plist文件来宣传服务,并在我构建应用程序时安装。 p>



EDIT: Now that I think about it, "Search With Google" must launch Safari every time in order to work, so this remark does not apply.

Perhaps I can put some logic in -applicationWillFinishLaunching/-applicationDidFinishLaunching to determine if the app is being launched in response to a service, and skip creating the window(notice the lack of withOptions: in OSX)?

But still, that doesn't feel right.

解决方案

It does have a lame version of withOptions: -- NSApplicationLaunchIsDefaultLaunchKey tells you if your application was launched to either:

So in your applicationDidFinishLaunching you can see if that key is in the notification and set to NO. Unfortunately, the main way to tell that it is one of the possibilities other than the Service, you have to detect and record whether or not you also got an application:openFile:, etc.

这篇关于提供OSX服务而不启动应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 00:45