• 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: Missing functionality in copy/paste of NSAttributedStrings? or of NSData?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Missing functionality in copy/paste of NSAttributedStrings? or of NSData?


  • Subject: Re: Missing functionality in copy/paste of NSAttributedStrings? or of NSData?
  • From: Michael Ash <email@hidden>
  • Date: Sun, 21 Jun 2009 20:22:26 -0400

On Sun, Jun 21, 2009 at 7:27 PM, James Stein<email@hidden> wrote:
> I use a few non-standard attributes in NSAttributedStrings.
> ("Standard" attributes are listed in the "Attributed Strings
> Programming Guide.")
>
> My first stumbling block is that such a string (or substring) in an
> NSTextView, when copied and pasted, will "lose" its non-standard
> attributes. (As an aside, the non-standard attributes will survive
> encoding and decoding, and are preserved by the 'copy:withZone'
> method.) It appears to me that the Cocoa methods for converting
> attributed strings to-and-from NSData objects assume the used of
> "standard" attributes; and it further appears to me that these
> conversions neglect to copy non-standard attributes.

While your question about how to accomplish this has been answered, I
just wanted to address the more philosophical question about why this
happens. Copy/paste is intended to work between applications, and as
such generally uses universally readable formats. Sometimes an
application will use a custom in-app format for special data that
doesn't apply to the outside world, but by necessity this means coming
up with your own format to represent that special data. This is
essentially what you're doing. Although you're using a standard class
to hold them, your custom attributes make this a custom format. Just
think of what would happen if the system encoded your custom
attributes along with everything else: the unarchiver would try to
decode those objects in the target application which doesn't contain
those classes, and would fail. It's much better to grab what the
system does know about than to fail in this manner.

Mike
_______________________________________________

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: 
 >Missing functionality in copy/paste of NSAttributedStrings? or of NSData? (From: James Stein <email@hidden>)

  • Prev by Date: Any Cocoa Developers on this list in Tallinn, Estonia?
  • Next by Date: Re: Show the dock icon's context menu:
  • Previous by thread: Re: Missing functionality in copy/paste of NSAttributedStrings? or of NSData?
  • Next by thread: Any Cocoa Developers on this list in Tallinn, Estonia?
  • Index(es):
    • Date
    • Thread