I'm trying to use cocoa bindings with nstableview and I have some problems with bind of parameter value of textfield:
I'm using this code, class:
class Person : NSObject {
var givenName:String
var familyName:String
var age = 0
var lol = 0
override init() {
givenName = "given"
familyName = "family"
lol = 36
super.init()
}
init(givenName:String, familyName:String, age:Int) {
self.givenName = familyName
self.familyName = givenName
self.age = age
self.lol = 36
super.init()
}
and view controller:
class ViewController: NSViewController {
@IBOutlet weak var tableViewL: NSTableView!
@IBOutlet var superResultsController: NSArrayController!
@objc dynamic var array = [Person]()
override func viewDidLoad() {
super.viewDidLoad()
array.append(Person(givenName: "sas", familyName: "gfg", age: 10))
array.append(Person(givenName: "sddsgds", familyName: "gfg", age: 10))
array.append(Person(givenName: "uoijh", familyName: "gfg", age: 10))
print(superResultsController.arrangedObjects)
}
I found that I can't bind textfield to any variable of my class - app crashes with bad_instruction error.
Here's my bindings of array controller and table view:
NSArrayController: