Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wenjuan5 opened this issue Feb 22, 2023 · 1 comment

Comments

@wenjuan5
Copy link

*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

@wenjuan5 wenjuan5 changed the title swift js 调原生,异步有传参和回调怎么写 求助 swift js 调原生,异步有传参和回调怎么写 Feb 22, 2023
@wenjuan5 wenjuan5 changed the title 求助 swift js 调原生,异步有传参和回调怎么写 求助 swift js 调原生,异步有传参和回调,点击报错[__NSCFString count] Feb 22, 2023
@wenjuan5
Copy link
Author

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

   completedHandler(convertDictionaryToString(dict: dic),true)

}

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant