class Codemanager {
static let instance = Codemanager()
public var codevc : CodeVC?
func compile_snippet(inputs : String,language : String, content: String) -> String{
Alamofire.request(apilink, method: .post, parameters: body , encoding: JSONEncoding.default, headers: headers).responseJSON
{(response) in
guard let data = response.data else { return }
do{
let json = try JSON(data: data)
print(json)
outputcode = json["stdout"].stringValue + "\n" + json["stderr"].stringValue + "\n" + json["error"].stringValue
self.codevc?.gotooutputscreen() //gotooutputscreen() is a function of CodeVC
}
catch{
debugPrint(error)
}
}
return outputcode
}
}
}
我的CodeVC代码如下:-
public func gotooutputscreen()
{
performSegue(withIdentifier: "tooutputscreen", sender: nil)
}
我无法从课堂上找出执行侦听的方法。
答案 0 :(得分:0)
您必须确保codevc
包含非nil值
Codemanager.instance.codevc = self