I am doing this to get the content of a file using NSOpenPanel, but I am getting a lot of weird stuff returned from the .rtf file I select.
My panel code:
That "other stuff" is the actual RTF data.
I would recommend using the NSAttributedString initializer NSAttributedString(path:documentAttributes:), which will read in and process the RTF data. Then you can access the plain text by using attributedString.string
.
In your case, it would be
if let content = NSAttributedString(path: expandedPath, documentAttributes: nil) {
// do something with content or content.string
}