• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Difficulties with recovering NSAttributedString attachments from saved RTFD
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Difficulties with recovering NSAttributedString attachments from saved RTFD


  • Subject: Re: Difficulties with recovering NSAttributedString attachments from saved RTFD
  • From: Martin Wierschin via Cocoa-dev <email@hidden>
  • Date: Sun, 1 Dec 2019 15:53:26 -0800

> let savedRtfd = originalString.rtfd(from:NSRange(0..<originalString.length))!

...
> 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 that are officially supported by
RTF/RTFD might not be roundtripped if Apple didn't add support for it.

A quick example: images in RTF data are discarded when loaded by
NSAttributedString. That's despite the fact that images are completely
supported by the RTF spec, NSTextAttachment, and even Apple's RTFD. It's just
that Apple didn't bother with RTF.

Maybe there's another data format where Apple better handles attachment
serialization? I don't know. But if I needed to reliably serialize all kinds of
attachments I'd probably do it myself to be sure, since I don't recall seeing
it mentioned explicitly.

~Martin Wierschin


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Next by Date: Future of Cocoa #2
  • Next by thread: Future of Cocoa #2
  • Index(es):
    • Date
    • Thread