0
我是Swift Mac App開發的新手,我從登錄窗口到顯示登錄URLRequest後的主窗口,以及在新的主窗口中創建另一個URLRequest的麻煩。如果我只是從一個窗口進入而不進行登錄URLRequest,它可以正常工作。異步調用後運行模態
func loadMainView() {
self.view.window?.close()
let storyboard = NSStoryboard(name: "Main", bundle: nil)
let mainWindowController = storyboard.instantiateController(withIdentifier: "MainViewController") as! NSWindowController
if let mainWindow = mainWindowController.window {
let application1 = NSApplication.shared()
application1.runModal(for: mainWindow)
}
}
func tryLogin(_ username: String, password: String) {
Staff.login(username: self.username.stringValue, password: self.password.stringValue) { (completed, result, staff) in
// DispatchQueue.main.async {
if completed {
if result == .Success && staff != nil {
DispatchQueue.main.async(execute: {
self.loadMainView()
})
} else {
self.dialogOKCancel(message: "Error", text: "Your credentials are incorrect")
}
} else {
print("error")
}
}
}
HTTPSConnection.httpGetRequestURL(token: token, url: digialOceanURL, mainKey: mainKeyVal) { (complete, results) in
DispatchQueue.main.async {
if complete {
}
}
}
我已經嘗試調用self.loadMainView()沒有執行,但仍然不是運氣。
任何幫助表示讚賞。謝謝
所以你有一些錯誤,或者你的意思是「沒有運氣」 –
對不起,主窗口中的第二個URLRequest不會出現在後臺線程中 – Tim
我們需要爲代碼,你沒有顯示任何東西,這段代碼沒有做任何嚴重的事情 –