Category Archives: Cocoa

NSTextField validation

Swift Language

Swift You want to sanitize user input before it gets into your model. Input validation can be brute force – you validate and set each field, or you can use Cocoa Bindings which will do both “automatically”. Introduction Using Bindings Error protocols Final thoughts Summary Resources Introduction Table of Contents I’ll start by setting up […]

Also posted in Swift | Tagged , | Leave a comment

Swift script to create a Cocoa window

Swift Language

Swift script to create a Cocoa window Create a Cocoa window with a functioning button from a command line Swift script. How To Summary Resources How To Table of Contents You probably know that you can run a swift program from the command line like a script.

Previously you had to use this incantation: […]

Also posted in Swift | 2 Responses

Swift NSTableView and NSArrayController

Swift Language

Swift NSTableView and NSArrayController In my NSTableView column chooser example, I used a table data source and delegate to manage the table’s data. Just like iOS. Cocoa offers other options. In this example, I’ll look at “binding” to an NSArrayController. Introduction Data Model Array Controller Table View Binding the columns Adding/Removing rows Summary Resources Introduction […]

Also posted in Swift | Tagged , | 7 Responses

Swift NSTable Column Chooser

Swift Language

Swift NSTable Column Chooser Although I wrote NeXTStep programs back in the 1980s for my dissertation, I haven’t written many Cocoa programs. The extra Apple Developer fee for OSX apps was something I didn’t want to pay in addition to the iOS fee. OK, I’m cheap. But how many bags of cat food would that […]

Also posted in Swift | Tagged | 8 Responses