Search code examples
swiftclassbindingtableviewnsarraycontroller

How to get value out of bound textfield in tableview?


It seems I cannot find a solution how to get value out of a textfield in tableview. Hope I can describe my problem accordingly. Here are two pictures of my setup in IB:

Picture1 Picture2

I have subclassed NSTextField in order to draw a new background. This is working so far. But coming to the challenge to get the cells value as a variable, I can´t find a solution. The cell is getting it´s value out of a NSArrayController binding. I tried with self.objectValue, self.stringValue I´m always getting nil. Making an outlet is not possible as well.

Here´s the code of my subclass:

class ProgressView: NSTextField {

    func getOwnValue() {

        // Here I´m getting always nil
        let ownValue = self.objectValue
        let ownValue2 = self.stringValue

    }

}

What am I missing? Help would be much appreciated.


Solution

  • found the solution:

    override var stringValue: String {
            didSet {
               Swift.print(stringValue)
            }
    }