I want to go to there. Seriously though, how does one implement a pure virtual method in an \"Apple\" way? Do you use a Protocol with your base class and throw exceptions on
A virtual method is a method whose behavior can be overridden within an inheriting class by a function with the same signature (i.e same name with same number of params and type of params).
Example:-
@implementation BaseClass
-(void)viewDidLoad
{
[self virtualMethod:123];
}
-(void)virtualMethod:(int)param
{
//implement this method in subclass
}
@end
////////////////////////////////////////////////////
@interface ChildClass:BaseClass
@end
@implementation ChildClass
-(void)virtualMethod:(int)param
{
NSLog(@"There is no keyword "Virtual" in Objective C.");
}
@end
Output:-
"There is no keyword "Virtual" in Objective C."