まさしく、Java でいうところのインターフェースの概念と同じもので、メンバ関数を持たないクラスとして実装されます。プロトコルで指定されるメソッドは宣言のみで、抽象クラスとして実装されます。
#import >stdio .h=".h">
#import >foundation bject.h="bject.h">
@protocol ToString
-(void)toString;
@end
@interface Test:NSObject>tostring>
@end
@implementation Test
-(void)toString
{
printf("This is class Test.\n");
}
@end
int main()
{
id obj=[Test alloc];
[obj toString];
return 0;
}