I am working through an example in  Buck/Yacktman's book that uses an informal 
protocol.

In the interface of of a custom class,  it is declared as such.


#import <Cocoa/Cocoa.h>


@interface MyShapeEditorDocument : NSDocument
{
    ....ivars....
}
@end


@interface NSObject(MYShapeEditingDocEditor)



-(void) controllerDidEndEditing;
@end


In the implementation file it is defined, twice, thus.


@implementation NSObject(MYShapeEditingDocEditor)

-(void) controllerDidEndEditing
{
        
}
@end

and in the main body of the code, thus.


@implementation MyShapeEditorDocument


-(void) controllerDidEndEditing
{
    [[self myView] setNeedsDisplay: YES];
    [[self table] reloadData];
}


Apple's docs say:  "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."  
(http://developer.apple.com/mac/library/documentation/cocoa/Conceptual/ObjectiveC/Articles/ocProtocols.html#//apple_ref/doc/uid/TP30001163-CH15-TPXREF147)


What I am not following is the seemingly double definitions. From the docs, it 
would seem that implementation is a 2 step process, not a 3 step as above, even 
though this is clearly correct. What is the essence that I am missing? 

Thanks._______________________________________________

Cocoa-dev mailing list ([email protected])

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to