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 […]

Sorting a Table View of Core Data Records

October 8th, 2014

Filed under: Cocoa, Mac Development | 1 comment

In my previous post, I detailed the steps needed to bind a view-based table view to a Core Data entity. That post is missing one thing: sorting, which I’m going to cover now. Add an Ordering Attribute to the Entity Core Data does not have built-in support for sorting records. If you want a collection […]

Binding a View-Based Table View to a Core Data Entity

October 7th, 2014

Filed under: Cocoa, Mac Development | 3 comments

My main reason for writing this post is to have a reference for myself in case I need to bind a view-based table in the future. If this post helps anyone else, that’s a bonus. Set up the Array Controller The first step is to create an array controller and configure it to control a […]