• 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: John Hörnkvist <email@hidden>
  • Date: Tue, 20 Nov 2001 18:44:51 +0100

On Tuesday, November 20, 2001, at 03:24 , John C. Randolph wrote:

On Monday, November 19, 2001, at 10:07 AM, Norbert Heger wrote:

But be aware of the fact, that even if an instance is immutable, it will be
a subclass of a mutable (abstract) superclass. Thus invoking [array
isKindOfClass:[NSMutableArray class]] will NOT tell you if the given array
is in fact mutable. Instead it always returns YES.

That's exactly reversed from what the docs and the headers both say about all of the Foundation collection classes. NSArray is the parent of NSMutableArray, NSSet is the parent of NSMutableSet, and so forth.

From a type system point of view, the immutable classes differ only in defining fewer methods than their mutable correspondents. For that reason, the immutable classes cannot be subclasses of mutable classes.

However, 10.0 behaved like Norbert describes; all collections were mutable. Apple chose not to implement a immutable collections, and used mutable collections everywhere instead. This, coupled with Objective-C's weak static type system, made some bugs very hard to detect.

Regards,
John Hornkvist
--
ToastedMarshmallow, the perfect Cocoa companion
http://www.toastedmarshmallow.com


References: 
 >Re: Mutability (From: "John C. Randolph" <email@hidden>)

  • Prev by Date: Re: Mixing Cocoa/Java problem
  • Next by Date: Re: Standard OS X Compression format
  • Previous by thread: Re: Mutability
  • Next by thread: Re: Mutability
  • Index(es):
    • Date
    • Thread