I going through Cocoa Programming for OS X
book by Big Nerd Ranch, and I'm stuck on Chapter 9 -- working with NSArrayController. This book is not up to date, so some things I had to search online to make it work.
I'm stuck on binding a TableViewCell to my object's key.
So I have an object:
import Foundation
class Employee: NSObject {
var name: String? = "New Employee"
var raise: Float = 0.05
}
This is binded to the NSArrayController Content Array.
The Document controller where the Employee
object is used is:
import Cocoa
class Document: NSDocument {
@objc dynamic var employees: [Employee] = []
override init() {
super.init()
// Add your subclass-specific initialization here.
}
override class var autosavesInPlace: Bool {
return true
}
override var windowNibName: NSNib.Name? {
return NSNib.Name("Document")
}
}
Everything works fine, and the result looks like this:
The problem is, when I set the binding for the Table Cell view, like so:
The program still loads up, but when I click Add Emplyee
, the program crashes with the error
Xcode Version: 10.1
Swift Version: 4
Thread 1: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
with no other information in the console as to the error.