Is there an easy way to load a text file with some formatting into a text view on a window?
Hi,
the text storage object (NSTextStorage) of a text view is a subclass of NSAttributedString which can hold formatting attributes. NSAttributedString (using Application Kit Additions) can read files as HTML or RTF data
I would probably need an example as so much of that is greek to me…
something like this, textView is the NSTextView instance
set fileURL to current application's NSURL's fileURLWithPath_("/path/to/file.rtf")
set RTFData to current application's NSData's dataWithContentsOfURL_options_error_(fileURL, 0, missing value)
set fileContents to current application's NSAttributedString's alloc()'s initWithData_options_documentAttributes_error_(RTFData, missing value, missing value, missing value)
if fileContents is not missing value then
textView's insertText_(fileContents)
end if