• 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: Ugly bug in Foundation, beware!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Ugly bug in Foundation, beware!


  • Subject: Re: Ugly bug in Foundation, beware!
  • From: Nicko van Someren <email@hidden>
  • Date: Thu, 3 Jun 2004 16:08:08 +0100

On 3 Jun 2004, at 15:21, Ondra Cada wrote:

On 3.6.2004, at 15:52, Nicko van Someren wrote:

The array class knows nothing of the objects it holds...

Exactly. And that's the very reason to make an immutable copy it MUST
send the objects -copy, storing whatever they return.

You missed my point. I was asserting that an NSArray is an array of references. A copy of an array of references is a new array containing the same references.

...
It's called object-oriented. You (in this case the array) don't know
and don't NEED TO know what the objects actually are. You just sent
them appropriate message, and they take appropriate action.

NSArray can't go around sending -copy messages to any old object, since there is absolutely no guarantee that the object is going to respond to it. The documentation for -copy in NSObject says it is a "Convenience method for classes that adopt the NSCopying protocol." If the objects referred to by the array don't all follow the NSCopying protocol then, in your world view, nor could the NSArray class. If you know that the objects in the container are going to be able to comply with the copying protocol then you can explicitly say so by using -initWithArray:copyItems: instead.

Alas in this case the message is not sent, and thus the action is not
taken :(((

They didn't send the message because they had no reason to believe it wouldn't raise an exception and if a deep copy is assumed then there is no sensible action to take when that exception is raised.

Nicko
_______________________________________________
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.


References: 
 >Ugly bug in Foundation, beware! (From: Ondra Cada <email@hidden>)
 >Re: Ugly bug in Foundation, beware! (From: Nicko van Someren <email@hidden>)
 >Re: Ugly bug in Foundation, beware! (From: Ondra Cada <email@hidden>)

  • Prev by Date: Re: Ugly bug in Foundation, beware!
  • Next by Date: Custom NSTextField Cell editing problems
  • Previous by thread: Re: Ugly bug in Foundation, beware!
  • Next by thread: Re: Ugly bug in Foundation, beware!
  • Index(es):
    • Date
    • Thread