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

Re: Mutability


  • Subject: Re: Mutability
  • From: Gregory Block <email@hidden>
  • Date: Thu, 22 Nov 2001 09:59:09 +0000

On 21/11/01 1:57 pm, "Ondra Cada" <email@hidden> wrote:
> NSArray *checkAndChangeIfNeeded(id array) { // OS X, clean but terribly
> ineffective
> ...
> if (some_condition) { // need to change
> array=[[array mutableCopy] autorelease];
> [array addObject:...]; // or insertObject or whatever...
> }
> ...
> return array;
> }

Shouldn't this be behavior *of your array object*, surely, and not of a
procedural call in some object that clearly isn't responsible enough for the
object's data to know what it actually contains?

If this was being encased properly in the first place, I'd argue, the whole
question would be moot, wouldn't it. Why isn't checkAndChangeIfNeeded:
being called on a NSThoughtIWasn'tMutableDidn'tYouArray? And how does
encapsulation of the data not solve this problem?


  • Follow-Ups:
    • Re: Mutability
      • From: Ondra Cada <email@hidden>
References: 
 >Re: Mutability (From: Ondra Cada <email@hidden>)

  • Prev by Date: Re: Variable Size Matrix
  • Next by Date: Re: Standard OS X Compression format
  • Previous by thread: Re: Mutability
  • Next by thread: Re: Mutability
  • Index(es):
    • Date
    • Thread