public delegate int Func0();
public delegate int Func1(int a);
public class TestClass{
public void test(){
doSth0(getNum0);
// #1 compile error: (E558) Parenthesis required for call in parameter 1 of Int32 TestClass.doSth0(Func0 f0)
doSth0(new Func0(getNum0));
// #2 compile ok, but will run into exception: 'NSInvalidArgumentException', reason: '+[Protocol getNum0]: unrecognized selector sent to class 0x10b793148'
doSth1(getNum1);
// #3 works fine
doSth1(TestFuncClass.getNum1);
// #4 compile ok, but will run into exception: 'NSInvalidArgumentException', reason: '+[Protocol getNum0]: unrecognized selector sent to class 0x10b793148'
}
public int doSth0(Func0 f0){
return f0();
}
public int doSth1(Func1 f1){
return f1(1);
}
public static int getNum0(){return 5;}
public static int getNum1(int a){return a;}
}
public static class TestFuncClass{
public int getNum1(int a){return a;}
}
I think #1 is a bug no doubt, but not sure about #2 and #4. Are they some by-design limitations?
Elements 8.2.89.1893
EmptyiOS.zip (111.0 KB)