How to add sheet to basic application

Hello, I'm using MacOS 10.12.4 with Xcode 8.3.2, Objective-C and can't find any useful documentation on how to add sheets to a MacOS storyboard app.


If there is some documentation or guide available, can you point it out to me?


Right now all I want to do is this: Launch app, have startup code look for some configured defaults and then when initial window is displayed immediately present a sheet which asks to enter/confirm required settings. OK button on sheet performs initialize actions and on error prints message to re-enter data, or if init is successful sheet goes away and app starts doing what it needs to do. Button on main app window invalidates existing init data and re-presents sheet to enter/confirm new desired settings. Think of it like a network client app where the app could connect to any number of network devices, so the app must prompt for desired settings first to initialize login to device, get basic data, then present GUI for interaction.


Anyway I've found references to creating new NSWIndow objects and loading data from XIB files on-demand. In Interface builder I figured out there is a way to use a view controller which is connected to a button and segue of type sheet, but I haven't been able to figure out how to make the sheet appear automatically, or how to dismiss the sheet once displayed.


Any pointers to get me started would be appreciated. I'm almost thinking to just use Apple's existing published doc on sheets from 2009, but likely there is a better way intended for MacOS SB use.


Thanks

Replies

I think I finally figured this out. I was able to label the popup segue item in IB with a name, and then from my view controller invoke


[self performSegueWithIdentifier:@"segueName" sender:self];

And I could use that to auto-trigger the popup on application start and also attach it to a button action.


Then clean up it up in the popup controller with:


[self dismissController:self]


I'm still trying to figure out how to kill the application when a popup is visible. The window has the red-X dissappear when the popup is open, and attempting to exit the application at this point doesn't work. I think the default popup action is rejecting the close action, I need to find how to trap that and cleanly close upt.