When i'm trying to call protocolA methods, on an object of protocolB, i'm getting compiler warnings", but how would i restrict it to only methods of protocolB, i mean it shouldn't allow me to run the code, it has to give me an error ??? Is there any method to solve this problem in Objective-C?
Example :
// this is protocolA.h
@protocol protocolA
-(void)methodA;
@end
//this is protocolB.h
#import "protocolA"
@protocol protocolB <protocolA>
-(void)methodB;
@end
//this is MyClass.h
#import "protocolA"
@interface MyClass <protocolA>
{}
@end
//this is MyClass.m
@implementation
-(void)applicationDidFinishLaunching
{
id<protocolA> objA = [[MyClass alloc]init];
[objA methodA];//Should work fine
[objA methodB];//**Sholud give me error, but only warning is prompted but able to access methodB using objA and print its contents**
}
-(void)methodA
{
NSLog(@"This is in protocolA");
}
-(void)methodB
{
NSLog(@"This is in protocolB");
}
@end
NOTE:Here i'm extending protocolA in protocolB, but when i create an object of protocolA in MyClass, i should be able to access only the methodA of protocolA not the methodB of protocolB.