@interface and @protocol explanation?

An interface is where you define the attributes and operations of class. You must set out the implementation too.

A protocol is like an interface for java.

e.g.

@protocol Printing
    -(void) print;
@end

can be implemented

by declaring (confusingly in the interface)

@interface Fraction: NSObject <Printing, NSCopying> {
//etc..

The confusing thing for java developers is that the curly braces {} are not the end of the interface e.g.

@interface Forwarder : Object
{
    id recipient; 
} //This is not the end of the interface - just the operations


- (id) recipient;
- (id) setRecipient:(id) _recipient; 
//these are attributes.

@end
//This is the end of the interface

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)