简体   繁体   中英

Cocoa: add another dock icon at runtime

Is it possible to add another icon to the dock at runtime without using [NSWorkspace launchApplication:] ?

How?


Before you say 'no': I am willing to use stuff like fork() etc.

I actually tried a bit with fork() but I get the error:

The process has forked and you cannot use this CoreFoundation functionality safely. You MUST exec().
Break on __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__() to debug.

通过例如[NSWorkspace launchApplication:]启动另一个应用程序。

If you want to add an additional icon to the Dock, Yuji's answer is the easiest solution.
If you want to change the existing icon of your app, you can create a Dock tile Plug-In.
Those Plug-Ins were introduced with Snow Leopard and they allow you to display small informations even when your app is not running. (Like iCal's icon, which always shows the current date).

Apple's Dock tile Plug-In docs: http://developer.apple.com/library/mac/#documentation/Carbon/Conceptual/customizing_docktile/CreatingaDockTilePlug-in/CreatingaDockTilePlug-in.html#//apple_ref/doc/uid/TP30000986-CH4-SW1

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM