• 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: only defined for abstract class
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: only defined for abstract class


  • Subject: Re: only defined for abstract class
  • From: Francis Derive <email@hidden>
  • Date: Thu, 6 Oct 2005 19:43:20 +0200


On Oct 6, 2005, at 4:10 PM, Mark Munz (DevList) wrote:


I'm assuming that the mutable version has an additional primitive that has to be overridden. Unfortunately Apple documentation on Class Clusters isn't great. Specifically, documenting which classes ARE class clusters and what the primitive methods for each are. NSData and NSMutableData documents what primitive methods are, NSArray and NSMutableArray do not.

I would file bugs on the documentation.




In fact, I had thought about this from the NSArray.h in Developer 's SDK :



/**************** Mutable Array ****************/

@interface NSMutableArray : NSArray

- (void)addObject:(id)anObject;
- (void)insertObject:(id)anObject atIndex:(unsigned)index;
- (void)removeLastObject;
- (void)removeObjectAtIndex:(unsigned)index;
- (void)replaceObjectAtIndex:(unsigned)index withObject:(id)anObject;

@end

there are also these categories, which I presume could add only but derived methods:

@interface NSMutableArray (NSExtendedMutableArray)

- (void)addObjectsFromArray:(NSArray *)otherArray;
- (void)exchangeObjectAtIndex:(unsigned)idx1 withObjectAtIndex: (unsigned)idx2;
- (void)removeAllObjects;
[...]
- (void)setArray:(NSArray *)otherArray;
- (void)sortUsingFunction:(int (*)(id, id, void *))compare context: (void *)context;
- (void)sortUsingSelector:(SEL)comparator;


#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
- (void)insertObjects:(NSArray *)objects atIndexes:(NSIndexSet *) indexes;
- (void)removeObjectsAtIndexes:(NSIndexSet *)indexes;
- (void)replaceObjectsAtIndexes:(NSIndexSet *)indexes withObjects: (NSArray *)objects;
#endif


@end

@interface NSMutableArray (NSMutableArrayCreation)

+ (id)arrayWithCapacity:(unsigned)numItems;
- (id)initWithCapacity:(unsigned)numItems;

@end



The concept article makes it clear that you can't call the inherited object for primitive methods.

I has yet to be clear to me - but I am obliged to be conviced.
By the way, if I understand well the third statement of a True Subclass : "Override the superclass's primitive methods", where does NSMutableArray overrides the NSArray's -count and -objectAtIndex: ? Bizarre.


You have to define that either as your own storage type, or the other option is the composite example (where you wrap around the NSMutableArray, in which case you have an embedded NSMutableArray).


I had done this way at first, but wanted to explore the alternative of subclassing ...

And I believe you'll need to override an additional method for storing the object in the case of sublcassing NSMutableArray. Not sure which method that is, as it isn't documented (as far as I can tell) and I haven't had to do it myself.

Hopefully that helps a bit.

Mark Munz



Hopefully the numerous answers I have at this moment give me some courage.


Cheers,


Francis. _______________________________________________ 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
  • Follow-Ups:
    • Re: only defined for abstract class
      • From: "Mark Munz (DevList)" <email@hidden>
References: 
 >only defined for abstract class (From: Francis Derive <email@hidden>)
 >Re: only defined for abstract class (From: Pontus Ilbring <email@hidden>)
 >Re: only defined for abstract class (From: Francis Derive <email@hidden>)
 >Re: only defined for abstract class (From: "Mark Munz (DevList)" <email@hidden>)

  • Prev by Date: Re: CoreData - sqlite - statement is still active
  • Next by Date: Printing multiple pages from drawRect:
  • Previous by thread: Re: only defined for abstract class
  • Next by thread: Re: only defined for abstract class
  • Index(es):
    • Date
    • Thread