• 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: Custom attachment in a text view
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Custom attachment in a text view


  • Subject: Re: Custom attachment in a text view
  • From: Douglas Davidson <email@hidden>
  • Date: Tue, 6 Nov 2007 14:09:28 -0800


On Nov 6, 2007, at 1:59 PM, David Sinclair wrote:

For the first problem, the recommended solution seems to be to subclass NSTextView to override -readablePasteboardTypes, - writablePasteboardTypes, -readSelectionFromPasteboard:type:, etc to add the new pasteboard type. Which works, mostly, except my implementation mangles the text if dragging a block of text containing my custom attachment, as opposed to the attachment by itself (which works fine). I'm not sure how to handle the former case.

I haven't solved the second problem, of my custom attachments vanishing when the text is saved to the data store. Looking at the NSTextStorage contents after inserting it, the attachment is there, but it seems to be stripped out when saving (by encoding as data for a binary Core Data attribute). Inserting an image attachment is saved correctly, though. Which makes me think I need to encode the attachment somehow, but an -encodeWithCoder: method in the cell isn't called. Do I need to create a temporary file and use a file wrapper (the attachment currently passes nil for - initWithFileWrapper:)? That didn't seem to help, but maybe I didn't do it right.

Here's what I sent to this list in response to another question earlier today:


"The issue here has to do with the formats used to store text on the pasteboard. Copy/paste can potentially take place between any two applications, so the pasteboard generally uses application-independent formats for the interchange of data. In this case, attachments are stored for pasteboard purposes as file contents. One option for you is to decide on a file format to represent the contents of your custom attachments, and use that as the contents of the file wrapper for copy/ paste purposes. In this, you should consider what you want to happen when text is copied and pasted from your application to another application--is there some suitable representation for your custom attachments that other applications would understand? Your application could then recognize these files by some means--by contents, or perhaps by extension--when they are pasted in, and substitute your custom attachment."

This would be applicable to your question about dragging or copy/ pasting a block of text containing your custom attachment. Your second question is probably the same problem, since it has to do with the storage of text in persistent formats.

Douglas Davidson



_______________________________________________

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


References: 
 >Custom attachment in a text view (From: David Sinclair <email@hidden>)

  • Prev by Date: Custom attachment in a text view
  • Next by Date: Re: Hexadecimal addition
  • Previous by thread: Custom attachment in a text view
  • Next by thread: Re: Custom attachment in a text view
  • Index(es):
    • Date
    • Thread