You can use the following snippet to hide the Dock tile of a process that is not active:
- (void)applicationWillResignActive:(NSNotification *)notification
{
ProcessSerialNumber psn = {0, kCurrentProcess};
TransformProcessType(&psn, kProcessTransformToBackgroundApplication);
if([self.window isVisible])
{
[self.window performSelector:@selector(orderFrontRegardless) withObject:nil afterDelay:0.05];
}
}
- (void)applicationWillBecomeActive:(NSNotification *)notification
{
ProcessSerialNumber psn = {0, kCurrentProcess};
TransformProcessType(&psn, kProcessTransformToForegroundApplication);
SetFrontProcessWithOptions(&psn, kSetFrontProcessCausedByUser);
}
Just add the above code to your app delegate and the app's Dock icon will vanish when the process resigns active.
To keep the window visible after the process was turned into an UIElement application, send a orderFrontRegardless
message. (Very hacky, I know - but that must be the price for the non-standard window/process handling)
Probably you should also maintain a Dock menu that allows your users to select hidden windows.
You could dynamically add entries from your "main" app. Details can be found in the "Dynamically Adding Menu Items With the Application Delegate" section of the Dock Tile Programming Guide.
Update:
I slightly changed the code sample above as the previous approach led to a non-responsive main menu after re-activating the app.