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

Re: NSDictionary design bug (was: Re: Ugly bug in Foundation, beware!)


  • Subject: Re: NSDictionary design bug (was: Re: Ugly bug in Foundation, beware!)
  • From: Ondra Cada <email@hidden>
  • Date: Mon, 7 Jun 2004 15:31:44 +0200

Marco,

On 7.6.2004, at 14:57, Marco Scheurer wrote:

> Yes but the copying of the keys brings no advantage to the user, and
> only adds burden:
>
> (1) if the key is immutable then copying is useless (and often
> defaults to retain anyway)
> (2) if the key is mutable then
> (2a) if its value does not change between storage and retrieval then
> copying is useless
> (2b) if its value change between storage and retrieval then you will
> not find your object anyway.
>
> So we have a protection that works only when it does not matter.

(2c) it's the actual value you are interested in, but it just
happens--for some out-of-your-control implementation reasons--to be
represented by a mutable string.

Say, you got a dictionary which saves user/password pairs, and an
NSTextView is used for the user name: since its -string happens
(happened when I last checked for sure) an NSMutableString, you have to
copy so as the dict works as intended.

Now, let's not argue over whether it is better in such a case to copy
at the dictionary level (as Cocoa creators and me happen to think) or
above it, at the controller level (as you and Marcel are so profoundly
sure). Just I wanted to point out there *is* a 2c which needs the copy
*somewhere*. I may add in my personal experience such cases happen
*very* often, but you can say it's my bad programming style ;)))
---
Ondra Hada
OCSoftware: email@hidden http://www.ocs.cz
private email@hidden http://www.ocs.cz/oc

[demime 0.98b removed an attachment of type application/pkcs7-signature which had a name of smime.p7s]
_______________________________________________
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: NSDictionary design bug (was: Re: Ugly bug in Foundation, beware!)
      • From: Marcel Weiher <email@hidden>
References: 
 >Re: NSDictionary design bug (was: Re: Ugly bug in Foundation, beware!) (From: Patrick Machielse <email@hidden>)
 >Re: NSDictionary design bug (was: Re: Ugly bug in Foundation, beware!) (From: Marco Scheurer <email@hidden>)

  • Prev by Date: Windowless printing ?
  • Next by Date: Java or C++ for cross-platform Cocoa/.NET?
  • Previous by thread: Re: NSDictionary design bug (was: Re: Ugly bug in Foundation, beware!)
  • Next by thread: Re: NSDictionary design bug (was: Re: Ugly bug in Foundation, beware!)
  • Index(es):
    • Date
    • Thread