Re: Difficulties with recovering NSAttributedString attachments from saved RTFD

2019-12-01 Thread Martin Wierschin via Cocoa-dev
> let savedRtfd = originalString.rtfd(from:NSRange(0.. recoveredAttachment.contents is still nil. Your core problem is RTF/RTFD encoding. There's simply no guarantee those formats will preserve everything that's supported by the Apple text system, including NSTextAttachment data. Even features

Re: Difficulties with recovering NSAttributedString attachments from saved RTFD

2019-11-29 Thread Gary L. Wade via Cocoa-dev
While it may seem redundant, what if you specify the document type in the document attributes? Also, you’re storing UTF8 data in the contents but specifying plain text; what if you specify it as UTF8 plain text? Also, the source code for TextEdit is available somewhere; maybe try seeing what

Re: Difficulties with recovering NSAttributedString attachments from saved RTFD

2019-11-27 Thread Jeff Younker via Cocoa-dev
So, I replaced... *let* recoveredString = NSMutableAttributedString(rtfd: savedRtfd, documentAttributes: *nil*)! ...with... *let* fw = FileWrapper(serializedRepresentation: savedRtfd)! *let* filePath = URL(fileURLWithPath: "/tmp/bar") *do* { *try*

Re: Difficulties with recovering NSAttributedString attachments from saved RTFD

2019-11-27 Thread Gary L. Wade via Cocoa-dev
You want to use a file wrapper rather than data and specify the document type in the attributes as RTFD. -- Gary L. Wade http://www.garywade.com/ > On Nov 27, 2019, at 10:18 AM, Jeff Younker via Cocoa-dev > wrote: > > I am having some difficulty with saving

Difficulties with recovering NSAttributedString attachments from saved RTFD

2019-11-27 Thread Jeff Younker via Cocoa-dev
I am having some difficulty with saving NSAttributedStrings as RTFD and then recovering them with attachments intact. I generate a string containing an attachment and turn that into RTFD. When I turn that RTFD back into an NSAttributedString, I get the .string back, and I get an attachment, but