PjotrC
PjotrC

Reputation: 331

Swift: How to prevent window to show up on launch?

I am writing a macOS Cocoa application with Swift and I don't know how to prevent, that the main window shows up on application startup. I want to check first, if there is a new version available on the server: if there is one, a spash screen should appear. I don't know how to accomplish this and couldn't find good information too. I also don't know how to get rid of the windows standard buttons like for closing the window. Any help?

Upvotes: 0

Views: 1912

Answers (1)

comrade
comrade

Reputation: 4710

Check settings of your main window in Xcode. There are some checkboxes which control window buttons and other settings in Attributes inspector.

enter image description here

You can disable or enable them programmatically when you accessing Window object.

For example you can implement this approach in WindowController like this:

class WindowController: NSWindowController {

    override func windowDidLoad() {
        super.windowDidLoad()

        window!.styleMask &= ~NSClosableWindowMask
    }

}

Previously you need to add your custom WindowController class to window controller object in storyboard (Identity inspector tab).

Upvotes: 1

Related Questions