0

JS code:

share({
text:"test text",
url:"http://codingnext.com",
callback:function(){
    console.log('test func');
  }
});

Objective-C code:

- (void)share:(NSDictionary *)params {
    NSString *text = params[@"text"];
    NSString *url = params[@"url"];
    JSValue *callBack = params[@"callback"];
    [callBack callWithArguments:nil];
  }

I got the right text and url ,but the wrong callback.I want to know why and how to fix it .

3
  • Did you see this question? Commented Mar 12, 2018 at 14:09
  • Possible duplicate of How can I pass a JavaScript callback function to Cocoa/Obj-C? Commented Mar 12, 2018 at 14:29
  • Yes,but my problem is different.The params and callback are mixed so the Obj-C code can't figure out which should turn to JSValue. And when I use params[@"callback"],the application exits. Commented Mar 12, 2018 at 15:21

0

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.