• 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: Copying Oddity
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Copying Oddity


  • Subject: Re: Copying Oddity
  • From: The Amazing Llama <email@hidden>
  • Date: Fri, 11 Jul 2003 10:44:48 -0700

This is a good point, and indeed I only stumbled across this as I was updating some code and changing an NSAttributedString to an NSTextStorage, and neglected to change a 'copy' to a 'retain'.

But in any case, I found it a little odd, as -copy is supposed to give a copy of the object. Is this the design pattern one should use when making a non-copying subclass of a copyable superclass? Or is this a special case?

On Friday, July 11, 2003, at 09:28 AM, Douglas Davidson wrote:


On Friday, July 11, 2003, at 09:03 AM, The Amazing Llama wrote:

I just noticed that
-[NSTextStorage copy]
will provide you with an NSConcreteAttributedString, and not an NSTextStorage at all.

This makes a certain amount of sense, because NSTextStorage does not conform to NSCopying, where it's superclass NSAttributedString does, but it was still a little odd to see.

So I suppose since the superclass implements -copy, the subclass must, but to just pass the message on is a little odd.

Is this expected behavior? Or should it return nil or something?

Note that the special behavior of NSTextStorage consists primarily in its relationship to its layout managers, and a layout manager can have only one text storage, so that a copy of a text storage would in any event be unable to keep the same layout managers. You can file a bug about the current behavior if you find it undesirable, but in general I would say that other methods are more appropriate for duplicating and transferring the contents of documents.

Douglas Davidson



Seth A. Roby The Amazing Llama < mail or AIM me at tallama at mac dot com>
"Life is like an exploded clown. It's really funny until you figure out what just happened."
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
  • Follow-Ups:
    • Re: Copying Oddity
      • From: Douglas Davidson <email@hidden>
References: 
 >Re: Copying Oddity (From: Douglas Davidson <email@hidden>)

  • Prev by Date: Temperature Converter example
  • Next by Date: Re: Copying Oddity
  • Previous by thread: Re: Copying Oddity
  • Next by thread: Re: Copying Oddity
  • Index(es):
    • Date
    • Thread