【发布时间】:2021-10-20 08:40:31
【问题描述】:
我需要调用 Tronweb.js ,然后调用 trxSendTest.js。所以需要检查 Tronwebis 是否被调用。
输出-
版本 = 未定义 版本未定义
do {
let TronWebJS = try String(contentsOf: Bundle.main.url(forResource: "TronWeb", withExtension: "js")!, encoding: .utf8)
let trxSendTest = try String(contentsOf: Bundle.main.url(forResource: "trxSendTest", withExtension: "js")!, encoding: .utf8)
jsContext?.evaluateScript(TronWebJS)
jsContext?.evaluateScript(trxSendTest)
let testFunction = jsContext?.objectForKeyedSubscript("tronweb.version.api")
print("version = \(testFunction!)")
if let version = jsContext?.evaluateScript("tronweb.version.api") {
print("version is \(version)")
}
}
catch {
print("An error occurred")
}
【问题讨论】:
-
请描述您遇到的问题。输出是什么还是你得到了错误?
-
version = undefined 版本未定义
-
我需要调用 Tronweb.js ,Tronweb.js 已添加到 Xcode 中。
标签: javascript ios swift xcode javascriptcore