Re: Saving NSAttributedString to a File
Re: Saving NSAttributedString to a File
- Subject: Re: Saving NSAttributedString to a File
- From: Quincey Morris <email@hidden>
- Date: Fri, 19 Dec 2014 22:14:49 +0000
On Dec 19, 2014, at 13:39 , Charles Jenkins <email@hidden> wrote:
>
> But when it comes time to save to a file format selected from AppKit additions (e.g. RTFFromRange:documentAttributes:), any unusual, application-specific attributes will be lost. There is no built-in file format you can select that will save just any arbitrarily named attribute.
>
> Am I right?
The real question is: what are you trying to do?
There is, of course, *one* format that preserves custom attributes. NSAttributedString conforms to NS[Secure]Coding, so you can archive it and write the archive to a data file. If this is part of a document save, that’s certainly the easiest approach.
Or, you might be able to use the RTFD approach, where the data is represented by a file package containing a file (in one of the standard text file formats), along with other file that describe the additional attributes that apply to the first file. (RTFD is about something slightly different, though — attachments, which are similar to but not identical to general custom attributes.) In this scenario, on re-opening the package, you’d read the text first, then re-apply the custom attributes afterwards.
Or, if you’re looking for a standard *exchange* format, then the answer is likely to be no, as Jens said.
_______________________________________________
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