Re: How do I give a set of methods to some objects but not others?
Re: How do I give a set of methods to some objects but not others?
- Subject: Re: How do I give a set of methods to some objects but not others?
- From: Mike Abdullah <email@hidden>
- Date: Fri, 24 Nov 2006 18:51:47 +0000
Maybe I've misunderstood your question, but can't you just create a
protocol? Have a look at NSObject.h for a good example.
Mike.
On 24 Nov 2006, at 15:20, Alan Smith wrote:
Hi all,
I have a bunch of classes that I want to be able to use a set of
methods. They'll fulfill a formal protocol in this way. The problem is
that they can't inherit the methods because they're already inheriting
from other objects that I didn't write and there is no multiple
inheritance in ObjC.
I could write a NSObject subclass with the methods in it and then pose
it as NSObject. But then all classes would have access to those
methods and I don't want just anyone using them because they would
cause a memory leak if used improperly.
I could write a category on NSObject and import it but then I'd have
to write a method for each method in the category calling the
respective one in the category. This would be redundant and not the
OOP way.
The reason I don't write the methods over-and-over again in each class
is because they would all be the same, exactly the same. They're
accessor methods and so they would be the same. I want to write the
methods only once and not multiple times.
This may be pretty confusing so if you have any questions please
ask me.
Thanks in advance, Alan
--
// Quotes from yours truly -------------------------
"You don't forget, you just don't remember."
"Maturity resides in the mind."
"Silence is the Universe's greatest gift."
"When the World realizes that religion really is unnecessary, then it
shall evolve."
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins (at) lists.apple.com
Help/Unsubscribe/Update your Subscription:
40gmail.com
This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden