2

Let me tell you from the beginning, I have this initial view controller. From which I go to home view controller, by presenting it from the initial view controller, and I perform performClose on initial view controller so that it get's closed.

Now I am in home view controller, from here I am presenting a view controller as sheet [ A ] .

Now am in A controller, from here I am presenting a view controller as sheet [ B ].

Now I am in B. Now I want to present my home view controller from B view controller. I can easily do that by getting the view controller from storyboard and presenting it using presentViewControllerAsModalWindow. But the problem is that at the same time, I want to close B. But I could not do it.

I have tried this B [ Code given below ], it does not seems to work, when I perform the action the mac produces a ting ting sound.

 if let window = self.view.window {
     window.performClose(self)
  }

I can do dismissController(self) in B controller, that's not the whole point. I don't wanna dismiss it, I just wanna completely close it and show home page. Or is there any other work around? All I wanna do is that, present home view controller from controller B by closing it [ B ].

I am very new to OS X environment, Please help me with this. Thanks in advance.

1 Answers1

1

I know this is an old question but nevertheless. I came across exact same problem and this is what I found:

    if NSApplication.shared().keyWindow?.contentView != self.view {
        self.view.window?.endSheet((self.view.window?.attachedSheet)!)
    }
Derreck
  • 383
  • 1
  • 4
  • 10