wendux / DSBridge-IOS

:earth_asia: A modern cross-platform JavaScript bridge, through which you can invoke each other's functions synchronously or asynchronously between JavaScript and native.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

求助 swift js 调原生,异步有传参和回调,点击报错[__NSCFString count]

wenjuan5 opened this issue · comments

*shareText - 分享到第三方app,调起分享弹窗。
输入参数:
{
shareText: "分享的文案内容" ,
shareUrl: "分享的url",
}

 返回值
 {
     "code":"0:成功,-1:失败",
     "msg":"msg"
 }

typealias JSCallback = (String, Bool)->Void
var feedbankHandler : JSCallback?
@objc func shareText( _ args:Dictionary<String, Any>){
let dic = [
"shareText": "分享的文案内容" ,
"shareUrl": "分享的url",
]

   feedbankHandler!(convertDictionaryToString(dict: dic),true)
    //convertDictionaryToString字典转json字符串
}

这种写法一直报错 shareText is not invoked ,since there is not a implementation for it

知道为何了,必须是
@objc func shareText( _ arg:String,completedHandler:JSCallback){
let dic = ["shareText": "112","shareUrl": "https://www.baidu.com"]

   completedHandler(convertDictionaryToString(dict: dic),true)

}

arg的参数就是string,不能改为其他的