NSPopover to start in a detached state

Here is the trick. Use the required delegate method detachableWindowForPopover: to do the work for you, like:

- (void) showPopoverDetached
{
    NSWindow* detachedWindow = [self detachableWindowForPopover:nil];

    [detachedWindow.windowController showWindow:nil];
}

Seems that the Apple engineers implemented detachableWindowForPopover: on a pretty smart way, I guess it uses the content view controller class, and will always create a singleton like instance of the detached window. Once detachableWindowForPopover: has called the presented window instance will be re-used no matter when and why it is called, called it directly (from a func like my sample above) or indirectly (e.g. when you drag out, detach, the popover from its original position)

This way they can prevent a popover being detached 'twice' and we can also implement the detached way programmatically, nice job from them!