I understand that the main advantage of Objective-C over C ++ is its ability to send messages to objects instead of calling its methods. Secondly, you are allowed to dynamically add a method to objects.
Suppose this is my object:
@interface MyClass : NSObject {} - sayHello; @end
I know that my code below will work even if - sayGoodbye not defined, but can someone complete this code and demonstrate how Objective-C can add methods to objects at runtime?
MyClass* o = [[MyClass alloc] init]; [o sayHello ]; [o sayGoodbye]; [o release ];
Roman source share