writing code to synchronize text in NSTextView