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

Re: subclassing NSMutableArray


  • Subject: Re: subclassing NSMutableArray
  • From: Chris Hanson <email@hidden>
  • Date: Thu, 1 Aug 2002 12:44:11 -0500

At 8:42 AM -0700 8/1/02, brian lee dae yung wrote:
Hello, i am having difficulties subclassing the NSMutableArray class.
I keep getting the following run time error message, implying that my
init methods are not written properly:

You need to brush up on the difference between is-a and has-a relationships in object-oriented design.

Your MxPriceSeries class probably shouldn't be a subclass of NSMutableArray; rather, it should have an instance variable of type NSMutableArray.

A good rule of thumb is "If you're trying to subclass a class in a class cluster, chances are you really want a has-a relationship." There may be cases where you really do want to create a new kind of array or mutable array, but those will likely be far more general than your MxPriceSeries class looks. For instance, someone in the last couple weeks was working on an OrderedDictionary/MutableOrderedDictionary class that keeps its keys in some particular order. That, to me, sounds like a reasonable time to subclass classes in a class cluster.

-- Chris

--
Chris Hanson | Email: email@hidden
bDistributed.com, Inc. | Phone: +1-847-372-3955
Making Business Distributed | Fax: +1-847-589-3738
http://bdistributed.com/ | Personal Email: email@hidden
_______________________________________________
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: 
 >subclassing NSMutableArray (From: brian lee dae yung <email@hidden>)

  • Prev by Date: Re: on NSString usage
  • Next by Date: Re: teaching a game to "speak" different languages
  • Previous by thread: subclassing NSMutableArray
  • Next by thread: Re: subclassing NSMutableArray
  • Index(es):
    • Date
    • Thread