iOS Question SubExists use cases

Alessandro71

Well-Known Member
Licensed User
Longtime User
I'm in the process of converting some apps from B4A to B4i
I stumbled multiple times in the different SubExist implementation: in B4A it has just 2 arguments, while in B4i it also requires and additional argument as the number of called sub args
So the following B4A code
B4X:
    If (SubExists(callback, "RefreshFPS")) Then
        CallSub2(callback, "RefreshFPS", 0)
    End If
will become
B4X:
    #if B4A
    If (SubExists(callback, "RefreshFPS")) Then
    #else if B4i
    If (SubExists(callback, "RefreshFPS", 1)) Then
    #end if
        CallSub2(callback, "RefreshFPS", 0)
    End If
this is clearly non elegant and it looks like a candidate for "code smell"

is there a better way to handle this?
can i skip SubExists at all and just all the function, even if it does not exist, with no side effects?
 
Top