I was wondering if someone can explain what is informal protocols in Objective C? I try to understand it on apple documentation and some other books but my head is still spi
Based on "Jonathan Sterling" answer, can i say the following code represent informal protocol?
Apple documentation:
"When used to declare a protocol, a category interface doesn’t have a corresponding implementation. Instead, classes that implement the protocol declare the methods again in their own interface files and define them along with other methods in their implementation files."
#import
@interface Cat1 : NSObject {
}
- (void) simpleMethod;
@end
@implementation Cat1
- (void) simpleMethod
{
NSLog(@"Simple Method");
}
@end
@interface Cat1 (Cat2)
- (void) addingMoreMethods;
@end
@interface MYClass : Cat1
@end
@implementation MYClass
- (void) addingMoreMethods
{
NSLog(@"Testing!");
}
@end
int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
MYClass *myclass = [[MYClass alloc] init];
[myclass addingMoreMethods];
[myclass release];
[pool drain];
return 0;
}