开发者

Deactivate agent app after launch in Cocoa

开发者 https://www.devze.com 2022-12-11 06:31 出处:网络
What method should be called to deactivate an app right after it\'s launch in applicationDidFinishLaunching: delegate method has been called? Or maybe there is a better place to do that? The documenta

What method should be called to deactivate an app right after it's launch in applicationDidFinishLaunching: delegate method has been called? Or maybe there is a better place to do that? The documentati开发者_运维技巧on for deactivate method for NSApplication says that I shouldn't call this method directly since AppKit knows better how to deactivate stuff.


Maybe using -[NSApplication hide:] would work, or perhaps activate another app using -[NSRunningApplication activateWithOptions:] (10.6 only, tho). However, I don't foresee many problems with using deactivate:.


It's not clear what you're trying to achieve.

You can use -hide: to deactivate your app. I also wouldn't hesitate using -deactivate if it actually does what you need. It's just that normal applications do not explicitly deactivate themselves; I think that's what the documentation is saying.

However, if you set LSUIElement in Info.plist your application should not become active when launched; it also won't have a menu bar or dock icon.

0

精彩评论

暂无评论...
验证码 换一张
取 消