Instantiating Views from Mac Storyboards

May 30th, 2017

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

This is another post I’m writing as a reference to myself in case I need to deal with this subject in the future. There may be better ways to instantiate views than what I describe here. I’m sharing this information because there’s not much information available on Mac storyboards. Reading the following articles may help […]


Creating a Simple Mac Application Using Cocoa, Swift, and Storyboards

March 31st, 2017

Filed under: Cocoa, Mac Development | 3 comments

I’ve noticed there aren’t many articles or tutorials online about writing Mac apps in Swift. To help fill the void I’m writing this tutorial that guides you through the creation of a simple Cocoa app in Swift. The app converts temperatures from Celsius to Fahrenheit. Enter a temperature in Celsius, click a Convert button, and […]


Adding Markers to Text Lists when Pressing the Return Key

December 12th, 2016

Filed under: Cocoa, Mac Development | 1 comment

I tried using Apple’s NSTextList class for creating ordered and unordered lists in an application I’m developing. I was able to create lists, but when I pressed the Return key inside an unordered list, no bullet was added. Because of this flaw in NSTextList I decided to implement my own class for lists. But I […]


NSTableView Disappearing Text

November 23rd, 2016

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

I was having a problem with disappearing text in a table view in a Mac application I’m developing. Selecting an item in the table view erased that item’s text from the table view. The table view is part of a split view. Dragging the split view’s divider erased the text from every item in the […]


Maintaining NSTextView Insertion Point After Core Data Save

November 21st, 2016

Filed under: Cocoa, Mac Development | 1 comment

I am working on a Mac journaling application that uses Core Data. The user interface consists of a table view and a text view. The table view contains a list of dates. Selecting a date fills the text view with what was written on that date. Use the text view to write. One problem I […]


Simple Ways to Customize NSSavePanel

September 8th, 2016

Filed under: Cocoa | Be the first to comment!

Cocoa provides the NSSavePanel class to open a save panel when the user wants to save a document. Save panels are initially configured for saving. The default button’s name is Save, and the panel’s title is also Save. Suppose your application exports documents to various file formats. Exporting is similar to saving so you would […]


NSTextView not Scrolling Vertically

November 6th, 2015

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

I had a problem with a text view that would not scroll vertically. The fix was to select the text view in Interface Builder and use the size inspector to make the text view resizable vertically.


Mac Storyboard Show Segues Involve Window Controllers

October 11th, 2015

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

I struggled with how to pass data between view controllers in a Mac storyboard show segue so I’m detailing how I solved the problem here. I hope it helps others who have a similar problem. Short version: a show segue involves window controllers, not view controllers. Implement prepareForSegue in a NSWindowController subclass. Background I’m writing […]


NSDocument initWithType in Swift 2

July 9th, 2015

Filed under: Cocoa | Be the first to comment!

I updated my document-based Cocoa application to Swift 2 in Xcode 7 using Xcode’s converter. The converter changed the initWithType method in my NSDocument subclass to the following: convenience init(type typeName: (String!)) { self.init() // Rest of initialization code here } After doing the conversion the Swift compiler crashed every time I built the project. […]


Connecting Menu Items to IBActions in a Mac Storyboard

February 23rd, 2015

Filed under: Cocoa, Interface Builder, Mac Development | 6 comments

A common pattern in Mac application development is to create a menu item, create an IBAction for that item in one of your classes, and connect the menu item to the IBAction. When the person running your application chooses that menu item, your application performs the IBAction. If you’re using storyboards to develop your Mac […]