Kodeco Forums

Windows and WindowController Tutorial for macOS

In this Windows and WindowController Tutorial for macOS, learn how to create a document based Cocoa app using modal windows and Sierra new tabbed interface.

This is a companion discussion topic for the original entry at https://www.raywenderlich.com/613-windows-and-windowcontroller-tutorial-for-macos

Thank you for the great tutorial!

Do you have an update of this for Swift 4 and XCode 9? The code for loading and displaying the second view controller
isn’t compatible with Swift 4…


Sorry this article won’t be updated anytime soon but luckily the swift fix items in Xcode do a perfect job on this code (I just checked) . Alternatively use Edit > Convert > To Current Swift Syntax on the final project to see what needs to be changed.

Most of the conversions are to do with storyboard identifiers so

"Word Count Window Controller"


NSStoryboard.SceneIdentifier(rawValue: "Word Count Window Controller")

you’ll need to change

dynamic var wordCount = 0
to @objc dynamic var wordCount = 0 in a couple of places


NSApplication.shared() becomes NSApplication.shared and thats about the size of it.

But Xcode will do all the work if you want it to. Just click the red dots in the source editor to reveal the fix item.

Thanks for reading.

Thank you Warren, appreciate it.

This tutorial is more than six months old so questions are no longer supported at the moment for it. We will update it as soon as possible. Thank you! :]