• 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: How do I save and restore a custom NSTextAttachmentCell?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How do I save and restore a custom NSTextAttachmentCell?


  • Subject: Re: How do I save and restore a custom NSTextAttachmentCell?
  • From: Michael <email@hidden>
  • Date: Thu, 17 Nov 2005 16:00:21 +0100

Am 16.11.2005 um 19:54 schrieb Douglas Davidson:

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.
That sounds good. But one question left to solve this puzzle for me: How do I load this data (RTFD + own data file) back into a NSTextView and instantiate my own NSTextAttachmentCell-subclasses? I assume I have to scan the attributed string and replace the cells of my custom attachments with instances of my own cell classes? Is this right or is there a more appropriate way?

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

Thank you Douglas.

Michael
_______________________________________________
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


  • Follow-Ups:
    • Re: How do I save and restore a custom NSTextAttachmentCell?
      • From: Douglas Davidson <email@hidden>
References: 
 >How do I save and restore a custom NSTextAttachmentCell? (From: Michael <email@hidden>)
 >Re: How do I save and restore a custom NSTextAttachmentCell? (From: Douglas Davidson <email@hidden>)

  • Prev by Date: New to Cocoa - need help with putting GUI on C app
  • Next by Date: Re: "ld: warning multiple definitions of symbol ..."
  • Previous by thread: Re: How do I save and restore a custom NSTextAttachmentCell?
  • Next by thread: Re: How do I save and restore a custom NSTextAttachmentCell?
  • Index(es):
    • Date
    • Thread