2

I want to call iOS native method using JSContext with two parameters.

-(void)log:(NSString*)msg; in JSExport works fine when called with viewcontroller.log(logmasg); where viewcontroller is set as JS["viewcontroller"] = objCobj;

with same settings how can I call methos with two parameters

-(void)iosMethod:(NSString*)param1 andParam:(NSString*)param2 I tried calling as viewcontroller.iosMethodandParam('I am 1','I am 2');

But it do not call that method. any help is appreciated .

1
  • Finally I got it working .making viewcontroller.iosMethodandParam('I am 1','I am 2'); to viewcontroller.iosMethodAndParam('I am 1','I am 2'); is solution to this. How it works dont know.If anyone have some clue you can share here. Commented Apr 3, 2014 at 9:03

1 Answer 1

0

You can use JSExportAs macro to a selector that take one or more arguments.

@protocol MyClassJavaScriptMethods <JSExport>

JSExportAs(iosMethodWithParam,
           -(void)iosMethod:(NSString*)param1 andParam:(NSString*)param2
           );

@end

In Javascript, you can use-

MyClassObject.iosMethodWithParam(param1, param2)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.