Re: How do I save and restore a custom NSTextAttachmentCell?
Re: How do I save and restore a custom NSTextAttachmentCell?
- Subject: Re: How do I save and restore a custom NSTextAttachmentCell?
- From: Douglas Davidson <email@hidden>
- Date: Wed, 16 Nov 2005 10:54:27 -0800
On Nov 16, 2005, at 8:19 AM, Michael wrote:
I successfully build a custom NSTextAttachmentCell subclass to
handle some own image representation. I'm able to add a attachment
using this cell to a text view programatically.
What do I need to do to save and restore my custom data and
instantiate my custom class? I would like to use my own data (some
strings and integers) instead of using the NSFileWrapper hold by
NSTextAttachment.
Probably the most convenient thing would be to store your strings and
integers in an NSData suitable for considering as the contents of a
file, from which you can create an NSFileWrapper. An archive or a
plist would be a simple way of doing this. You would probably want
to pick a suitable extension to distinguish the names of these files.
An alternative would be to define a custom subclass of
NSTextAttachment that would store your custom data rather than an
NSFileWrapper. However, this would not work when saving the
attributed string to standard formats like RTFD; instead, you would
need to archive the attributed string (and support coding in your
custom subclass).
Douglas Davidson
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden