wonder Expert Licensed User Longtime User May 20, 2019 #1 Hi! Since Try/Catch doesn't work with CallSub, is there a way to check if a method exists in a given class (instance)? Edit: Solved! B4X: Sub SafeCallSub(class As Object, method As String) As Object If SubExists(class, method) Then Return CallSub(class, method) Return Null End Sub Last edited: May 20, 2019
Hi! Since Try/Catch doesn't work with CallSub, is there a way to check if a method exists in a given class (instance)? Edit: Solved! B4X: Sub SafeCallSub(class As Object, method As String) As Object If SubExists(class, method) Then Return CallSub(class, method) Return Null End Sub
Erel B4X founder Staff member Licensed User Longtime User May 20, 2019 #2 Yes. SubExists. Better to use XUI.SubExists if you are writing cross platform code. Upvote 0
wonder Expert Licensed User Longtime User May 20, 2019 #3 Erel said: Yes. SubExists. Better to use XUI.SubExists if you are writing cross platform code. Click to expand... OMG!!! The solution was right in front of me and I was meddling with Reflection and JavaObject all the time!! Thank for the quick answer and sorry for wasting your time with such a trivial question. Upvote 0
Erel said: Yes. SubExists. Better to use XUI.SubExists if you are writing cross platform code. Click to expand... OMG!!! The solution was right in front of me and I was meddling with Reflection and JavaObject all the time!! Thank for the quick answer and sorry for wasting your time with such a trivial question.