What exactly does "adopt a protocol" mean in the Objective-C / Cocoa documentation ?

Posted by driis on Stack Overflow See other posts from Stack Overflow or by driis
Published on 2010-05-16T15:58:14Z Indexed on 2010/05/16 16:10 UTC
Read the original article Hit count: 217

Filed under:

I am a C# developer getting started on Objective-C / Cocoa Touch programming. I think I might have gotten some terms wrong because I keep thinking about them "the C# way". Specifically, I have come around the term "protocol" in various documentation and tutorials.

In Objective-C, what exactly is a protocol ? Can it be compared to a C# interface ?

Is the following declaration the same as saying "The class is implementing the protocol UITextFieldDelegate" ? Or is UITextFieldDelegate to be compared with a generic type parameter in C# ?

@interface MyViewController : UIViewController <UITextFieldDelegate> { }

© Stack Overflow or respective owner

Related posts about objective-c