Hi,
I'm trying to figure out how an
NSViewController
can check if it was presented as a popvoer, so it might by notification and delegate pattern inform observers and let delegate act upon disappearing of the popover by overriding viewWillDisappear
method.So far I've with this solution:
- (BOOL)isPresentedAsPopover {
id popoverFrameClass = NSClassFromString(@"NSPopoverFrame");
id ourSuperViewClass = [[[self view] superview] class];
return [ourSuperViewClass isEqualTo:popoverFrameClass];
}
I've found that when a
NSViewController
is presented as popover programmatically via presentViewController:asPopoverRelativeToRect:ofView:preferredEdge:behavior:
method its view gets embedded in a NSPopoverFrame
class view.Which seems to be part of a class cluster pattern, hence it's a private class. I don't like this kind of solution, knowing that in future this could change etc.
Is there a better way to do that, rather than setting boolean property value in the View Controller when presenting it programmatically as a popover?