0

So I'm currently working on a plain text editor and I'm having a problem with NSDocument. When I try to open a file (read function) the opened window textField (ViewController().textField)has no stringValue.

I hope somebody is able to help, thanks in advance. c:

override func data(ofType typeName: String) throws -> Data {
    return textField.stringValue.data(using: String.Encoding.utf8, allowLossyConversion: false)!
}

override func read(from data: Data, ofType typeName: String) throws {
    if data.count > 0 {
        self.contents = NSString(data: data, encoding: String.Encoding.utf8.rawValue) as String!
    }

}
Ezekiel
  • 91
  • 11

0 Answers0