Is it possible in obj-c to pass some custom code to method in protocol with out creating new class for this purpose ? I spend some time in Java and things like below are pretty comfortable
interface TestInterface {
void onTest();
}
class testClass{
void main {
TestInterface test = new TestInterface(){
@Override
void onTest(){
// some custom code
}
};
someTestMethod(test);
}
private someTestMethod(TestInterface pDelegate){
if (pDelegate != null){
pDelegate.onTest();
}
}
}
Basically is it possible to init protocol variable and override its method?