Re: Extending NSMutableDictionary what am I doing wrong?
Re: Extending NSMutableDictionary what am I doing wrong?
- Subject: Re: Extending NSMutableDictionary what am I doing wrong?
- From: Sherm Pendley <email@hidden>
- Date: Fri, 27 Feb 2004 08:20:41 -0500
On Feb 27, 2004, at 7:29 AM, Stefan Pantos wrote:
no real way of know if a method is primitive or not till you try it
unless they structure the interface is a way to make it obvious?
True, there's no separate section in clustered classes documentation
where it explicitly lists the primitive methods - the information is
buried within the text description of the class. But it *is* there, so
there's no guesswork required. For example:
NSArray, 5th paragraph: "NSArrays two primitive methodscount and
objectAtIndex:provide the basis for all other methods in its
interface."
NSDictionary, 8th paragraph: "NSDictionarys three primitive
methodscount, objectForKey:, and keyEnumeratorprovide the basis for
all of the other methods in its interface."
I've also noticed a pattern in the header files of the classes I've
looked at. Each class appears to be first defined with only its
primitive methods, and the other methods added in a separate "extended"
category. So, at the top of NSArray.h we have:
@interface NSArray : NSObject <NSCopying, NSMutableCopying, NSCoding>
- (unsigned)count;
- (id)objectAtIndex:(unsigned)index;
@end
@interface NSArray (NSExtendedArray)
...
I've successfully created concrete subclasses of both NSMutableArray
and NSMutableDictionary, providing new primitive methods that use a
completely different storage mechanism - in my case, they provide a
thin Cocoa interface to Perl's equivalent storage structures. You can
go to <
http://www.sourceforge.net/projects/camelbones/> and browse
through CVS for NSPerlArray and NSPerlHash classes if you'd like to
have a look at them.
sherm--
_______________________________________________
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.