Strange Question
Strange Question
- Subject: Strange Question
- From: Edwin Zacharias <email@hidden>
- Date: Mon, 1 Jul 2002 22:08:12 -0400
If protocols define an interface and categories extend an interface, why
not have categories for protocols? For example, say I want to add the
method "autoreleasedCopy" to every object that supports the <NSCopy>
protocol. Where do I add this? If I add it using a category of
NSObject then it only works for subclasses of NSObject. This is what
Apple did with "copy". Now every NSObject subclass says it responds to
the copy selector even though it actually can't. In my opinion, this is
terrible.
Here's what I want to do. Rather than applying a category to a specific
class, I want to apply a category to all classes that support a certain
protocol. Looking at the ObjC runtime, I see that each class stores its
supported protocols and methods. When the class loads I want the loader
to check what protocols are supported and add methods based on this.
I think I could do this myself since the compiler is open source, but
I'd like to get feedback first. Comments on why or why not this is good
OOP would be very appreciated.
- Edwin
_______________________________________________
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.