Jul 18, 2008

(Objective-c) How to realize multiple inheritance

The Objective-c is single inheritance, but using Protocol allows to implements multiple class's methods, just like Interface in JAVA.

Here is an example :

@protocol MouseListener
-(BOOL) mousePressed;
-(BOOL) mouseClicked;
@protocol KeyboardListener
-(BOOL) keyPressed;
@interface Toto : NSObject

So in the implementation of Toto we could override these listener's methods.

No comments: