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

Re: Subclassing a NSMutableArray


  • Subject: Re: Subclassing a NSMutableArray
  • From: glenn andreas <email@hidden>
  • Date: Thu, 16 Mar 2006 10:24:27 -0600


On Mar 16, 2006, at 9:57 AM, Lorenzo wrote:
But subclassing an anbstarct class like NSMutableArray seems to be
impossible. Is it true?
I get this

exception: *** -count only defined for abstract class.  Define
-[XYCustomArray count]!

What do you suggest?


Just use a category to extend NS(Mutable)Array to add your routine - no need to subclass at all (not only does subclassing a class cluster get tricky to do right, you rarely want to be doing that anyway).


@interface NSArray(SetParam)
- (void)setParam:(int)par to:(float)newValue verbose:(BOOL)verbose;
@end

@implementation NSArray(SetParam)
- (void)setParam:(int)par to:(float)newValue verbose:(BOOL)verbose
{
    int i, totObjects = [self count];
    for(i = 0; i < totObjects; i++){
        id item = [self objectAtIndex:i];
        [item setParam:par to:newValue verbose:verbose];
    }
}
@end


Glenn Andreas email@hidden <http://www.gandreas.com/> wicked fun! quadrium | build, mutate, evolve | images, textures, backgrounds, art

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Subclassing a NSMutableArray (From: Lorenzo <email@hidden>)

  • Prev by Date: Re: Hyperlink in an NSTableView
  • Next by Date: NSTextView question
  • Previous by thread: Subclassing a NSMutableArray
  • Next by thread: Re: Subclassing a NSMutableArray
  • Index(es):
    • Date
    • Thread