• 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: Problem overriding NSMutableArray?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problem overriding NSMutableArray?


  • Subject: Re: Problem overriding NSMutableArray?
  • From: "John C. Randolph" <email@hidden>
  • Date: Thu, 31 May 2001 03:45:06 -0700

On Wednesday, May 30, 2001, at 02:27 PM, Michael Rogers wrote:

I have a class called PhotoAlbum that subclasses NSMutableArray, but when I call either
[self objectAtIndex:0];
or, just for completeness,
[super objectAtIndex:0];

within a method of NSMutableArray, I get this message:

May 30 16:01:49 PhotoAlbum[880] An uncaught exception was raised
May 30 16:01:49 PhotoAlbum[880] *** -objectAtIndex: only defined for abstract class. Define -[PhotoAlbumArray objectAtIndex:]!
May 30 16:01:49 PhotoAlbum[880] *** Uncaught exception: <NSInvalidArgumentException> *** -objectAtIndex: only defined for abstract class. Define -[PhotoAlbumArray objectAtIndex:]!

I find this somewhat confusing, because NSMutableArray isn't abstract.

Actually, it is abstract. If you create a mutable array, what you'll get typically is an instance of NSConcreteMutableArray.

What the documentation says is:

NSArray and NSMutableArray are part of a class cluster, so arrays are not actual instances of the NSArray or NSMutableArray classes but of one of their private subclasses. Although an array's class is private, its interface is public, as declared by these abstract superclasses, NSArray and NSMutableArray.


Subclassing a class cluster like NSArray or NSMutableArray is rarely necessary. What does your PhotoAlbum class do that NSMutableArray doesn't? Have you considered just adding that functionality in a category?

-jcr


"The problem with trying to child-proof the world, is that it makes people neglect the far more important task of world-proofing the child." -- Hugh Daniel


References: 
 >Problem overriding NSMutableArray? (From: Michael Rogers <email@hidden>)

  • Prev by Date: Re: Problem overriding NSMutableArray?
  • Next by Date: "public header"
  • Previous by thread: Problem overriding NSMutableArray?
  • Next by thread: Problem overriding NSMutableArray?
  • Index(es):
    • Date
    • Thread