Re: Informing one class about another class's methods
Re: Informing one class about another class's methods
- Subject: Re: Informing one class about another class's methods
- From: Karsten <email@hidden>
- Date: Thu, 23 Aug 2007 18:27:40 +0200
i think a superclass should not really know about its subclasses and
its methods... but you could implement the missing method also in the
superclass as some sort of abstract method:
- (void)someStuff
{
NSLog(@"subclasses should implement this method");
}
Kind Regards
Karsten
Am 23.08.2007 um 15:36 schrieb Boris Remizov:
On Aug 23, 2007, at 15:45 , Roland Silver wrote:
Suppose this:
1. Sub is a subclass of Super, hence it has a <#include "Super.h">;
2. Sub defines the method sub;
3. Super defines a method whose code contains the message: [Sub sub].
How can I get Super to know about Sub's sub method? Having a
<#include "Sub.h"> in Super.m causes a compiler error, while
<@class Sub;> tells Super that there's a Sub class, but nothing
about its methods.
Using protocols somehow? But I don't want to implement the sub
method in Super, I just want to let Super know about it.
-- Roland Silver <email@hidden>
You may declare a protocol eg. SubMethodInvocating with this sub
method
@protocol SubMethodInvocfting
- (type) sub;
@end
and then in Super's method that using reference to the Sub class
specify id pointer with this protocol.
- (void) supersMethodThatCallsSudsMethod: (id<SubMethodInvocating>)
objectReference
{
...
[objectReference sub];
...
}
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please 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:
40briksoftware.com
This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please 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