Checking Modifier Keys in Swift

January 22nd, 2018

Filed under: Cocoa, Mac Development | Be the first to comment!

Checking for modifier keys (Command, Control, Option, and Shift) when handling events is different in Objective-C and Swift. In Objective-C you perform a bitwise AND operation to check if modifier keys were held down. In Swift you check if the event’s modifier flags contains the specific modifier key. The following example demonstrates how to check […]


Saving Settings with Core Data Metadata

November 6th, 2017

Filed under: Cocoa, iOS Development, Mac Development | Be the first to comment!

I’m working on a Core Data app where I needed to save some document settings. Creating Core Data entities for these settings was overkill. In my research for a solution I discovered persistent store metadata. I did not find much information online on using persistent store metadata so I’m sharing what I learned in this […]


Xcode 9: Cocoa Xib File Projects Return

September 19th, 2017

Filed under: Cocoa, Mac Development, Xcode | Be the first to comment!

Xcode 8.3 removed the Use Storyboards checkbox for new Cocoa application projects. The checkbox has returned in Xcode 9 so you can choose whether to use storyboards or xib files for your project’s user interface.


Custom Notifications in Swift

September 8th, 2017

Filed under: Cocoa, Mac Development | Be the first to comment!

Notifications allow an object of one class to send a message for an object of another class to handle so the two classes don’t have to know about each other. The Cocoa framework has dozens of notifications, but you can also create your own. Using custom notifications involves the following steps: Get the notification center […]


Creating a Document-Based Mac Application Using Swift and Storyboards

August 7th, 2017

Filed under: Cocoa, Mac Development | 4 comments

I continue my writing on crafting modern Cocoa applications with Swift and storyboards. In this article you’ll learn about building document-based Cocoa applications by developing a simple text editor. I hope this article and project provide a gentle introduction to building document-based Cocoa applications in Swift. If you haven’t read it already, I recommend reading […]