Deactivate agent app after launch in Cocoa
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.
加载中,请稍侯......
精彩评论