Alex Rivera | Logout

@interface and @protocol explanation?

Asked 2009-11-05T08:38:34.733
85

I would like to know what the @interface in objective C is? is it just where the programmer want to declare the variables, class name or method names...? I am not sure whether it is like interface in Java. And about the @protocol in objective C as well. It seems like the interface in Java more. Could anyone give me detail explanation please. I truly appreciate it.

Edit
Report

1 Answer

16

The @interface in Objective-C has nothing to do with Java interfaces. It simply declares a public interface of a class, its public API. (And member variables, as you have already observed.) Java-style interfaces are called protocols in Objective-C and are declared using the @protocol directive. You should read The Objective-C Programming Language by Apple, it’s a good book – short and very accessible.

answered 2009-11-05T08:47:31.720

Your Answer