PDA

View Full Version : Virtual interface




ncohen
Jun 3, 2009, 04:57 PM
Hello,
I would like to create an interface without implementation... it would be an interface of a class which makes reference to the methods only. Is it possible to do that?

For example:

Superclass.h


@interface Superclass : NSObject
{

}
-(void)method1;
-(void)method2;
@end



Subclass.h


@interface Subclass : Superclass
{
int variable1;
int variable2;
}
-(void)method1;
-(void)method2;
@end



Subclass.m

@implementation Subclass
-(void)method1
{
// some code
}

-(void)method2
{
// some code
}
@end


This code doesn't work... is it possible to do something like that?

Thanks



lee1210
Jun 3, 2009, 05:05 PM
You want a protocol:
http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/Articles/ocProtocols.html#//apple_ref/doc/uid/TP30001163-CH15-SW1

-Lee