class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() clorse { (json) in print(json) } } func clorse(completion:@escaping (_ json: [String])->()) { let workingQueue = DispatchQueue(label: "workingQueue") workingQueue.async { // 延遲操做 print("努力工做") Thread.sleep(forTimeInterval: 2.0) let json = ["ac","mym"] DispatchQueue.main.async { print("結束工做") // 主線程更新 回調 completion(json) } } } }