iOS has [object respondsToSelector:@selector(selector)] to check if selector exists or not.
On 5/28/14 12:05 PM, "Erik Jan de Wit" <[email protected]> wrote: > >> >> I don't know, it very much could be. It could be that this makes sense >>in >> Obj-C but not in Java based on how they handle NoSuchMethod. I'd >>prefer to >> not have to rely on an exception being caught, especially since it could >> suppress other exceptions being thrown that I want to know about. > >Sending a message (calling a method) in object-c for a method that >doesn¹t exist will also throw an exception, I haven¹t looked at the >implementation but I would suspect that there is a test to see if the >method (selector) is there. > >> >> Also, I'm assuming the exception is NoSuchMethod, which isn't a safe >> assumption given that each device has their own quirks and this isn't >> guaranteed. > >One could just lookup if the method exist and not just try to invoke it >and wait for the NoSuchMethod. That way one could make the error handling >nicer, for example: > >You have a method called ŒmyAction¹ but it does not have the proper >method signature! Found public void myAction() but should be pubic >PluginResult myAction(JSONArray, CallbackContext) >
