Re: subclassing NSMutableArray
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.