Add / remove application icon from dock at runtime?

Is there a public Apple API that allows you to remove the application icon at the application level at runtime? I tried to substitute an empty view with a zero size through NSApplication dockTile, but that just erases the dock icon without fixing its space and launch indicator. I also know about the LSUIElement parameter in the info.plist application, but this value is evaluated only at startup. This is not a runtime parameter.

+4
source share
1 answer

This is a one-way street. You can configure the application to NSUIElement to hide the dock icon, and then call [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular]; to show it in the dock, but after that you cannot delete it. This way, you can make the dock icon a custom user, but you have to restart the application to hide the icon.


EDIT

You can call setActivationPolicy:NSApplicationActivationPolicyProhibited to hide the dock icon again - user1592530 Sep 18 12 at 2:21 pm

The comment is correct. There are two ways these days - Daij-Djan Dec 24 '12 at 11:46


+4
source

Source: https://habr.com/ru/post/1383723/


All Articles