I am working on a simple Document macOS application in Xcode 9 / swift 4 using XIB for the interface.
I have a TextView, the value of which I want to bind to a variable in the File's Owner's class.
The xib file is called Document.xib, the Owner class "Document"
class Document: NSDocument {
// Main text content
public var text : NSAttributedString = NSAttributedString ()
}
The value binding property of the TextView looks like this:
Now the little grey exclamation mark means that Xcode cannot resolve the entered keypath.
The debugger says that this class is not key value coding-compliant for the key text.
I do not know what that means, and I how I can fix this. As I am a newbie, please help. I'm sure it is something very simple for someone more experienced.
UPDATE: For binding purposes you need to declare the text variable as @objc dynamic, so Cocoa (Objective-C) can access it I guess:
class Document: NSDocument {
// Main text content
@objc dynamic var text : NSAttributedString = NSAttributedString ()
}
@objc dynamic
– Cruse