EXC_BAD_ACCESS when performSelector

public static class Program
{
    public int doSth1(){
        return 1;
    }

    public void doSth2(){
        var obj = new object();
    }

    public int Main(int argc, AnsiChar** argv)
    {
        // EXC_BAD_ACCESS (code=1, address=0x1)
        this.performSelector(__selector(doSth1));    
        this.performSelector(__selector(doSth2));
    }
}

EmptyiOS.zip (110.8 KB)

It seems that this issue is related to Element’s ARC. I’ve tried equivalent objc code which works.

Sort of. performSelector says it’s returns an id, but in reality, it doesn’t in this case:

Also note this line:
The aSelector argument should identify a method that takes no arguments. For methods that return anything other than an object, use NSInvocation.

Indeed, performSelector is defined to only be safe for methods returning an object or void, afaik.

not even void.