• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
question about informal protocols
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

question about informal protocols


  • Subject: question about informal protocols
  • From: Michael de Haan <email@hidden>
  • Date: Fri, 20 Nov 2009 11:46:17 -0800

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@hidden)

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:

This email sent to email@hidden

  • Follow-Ups:
    • Re: question about informal protocols
      • From: Jean-Daniel Dupas <email@hidden>
  • Prev by Date: Re: extracting the mantissa for a NSDecimal
  • Next by Date: Re: question about informal protocols
  • Previous by thread: Re: Core Data: rules for custom managed object setter implementations
  • Next by thread: Re: question about informal protocols
  • Index(es):
    • Date
    • Thread