我正在嘗試使用utils來執行kotlin
中的網絡操作。我有下面的代碼主要構造函數採取Command
和Context
。如何訪問Koltin中的靜態伴侶對象中的實例變量
我無法訪問command.execute(JSONObject(jsonObj))
中的命令變量,出現以下錯誤。我不確定是什麼導致問題?
未解決的引用:命令
class AsyncService(val command: Command, val context: Context) {
companion object {
fun doGet(request: String) {
doAsync {
val jsonObj = java.net.URL(request).readText()
command.execute(JSONObject(jsonObj))
}
}
}
}