I check for and remove spaces from a NSTextField
in controlTextDidEndEditing
, but these changes are not reflected in the cocoa bindings (the CoreData entry is not updated). The NSTextField
is updated, but if you click out of the entry and go back in the spaces come back. How can I trigger the bound object to update the data store?
I am bound to .value for the NSTextField
, I even tried setting .objectValue to .stringValue after the update, but it didn't work.
override func controlTextDidEndEditing(obj: NSNotification) {
Swift.print("editing is done now")
let textField:NSTextField = obj.object as! NSTextField
//if last character is a space remove it.
while textField.stringValue.characters.last == " "
{
Swift.print("last char is a space")
textField.stringValue.removeAtIndex(textField.stringValue.endIndex.predecessor())
}
//save to database now.
let dele:AppDelegate = NSApplication.sharedApplication().delegate as! AppDelegate
dele.saveAction(nil)
}