【发布时间】:2020-10-15 12:00:27
【问题描述】:
抱歉,这可能是一个真正的新手问题。我有一些 API 代码会消失并调用 Web 服务。当它返回时,我想获取该值并将其显示在 UI 中,但我很难了解是什么方法允许我这样做。到目前为止,我的 ViewController 中有这个..... '''
@IBAction func getToken(_ sender: NSButton) {
let cli = WSTokenServiceClient()
let rq = SecurityTokenRequest()
rq.UserName = "byname"
rq.Password = "abcdefg"
cli.GetUserWSToken(securityTokenRequest: rq, completionHandler: {(rep, err) in
NSLog(rep?.xmlResponseString ?? "none") //This successfully contains the string value I want
//token.stringValue = "jim" ///This doesn't work, it errors: NSControl.stringValue must be used from main thread only
})
}'''
如果有任何提示可以解决这个问题,我将不胜感激。
谢谢
【问题讨论】:
标签: swift api user-interface handler completion