【发布时间】:2018-02-23 09:19:45
【问题描述】:
当我使用Swift4in Xcode 9 给我时
UIApplication.delegate 只能在主线程中使用
....只能在主线程中使用
从后台线程组调用的 UI API
紫色警告。
我的代码;
var appDelegate = UIApplication.shared.delegate as! AppDelegate
public var context = (UIApplication.shared.delegate as! AppDelegate).persistentContainer.viewContext
let prefs:UserDefaults = UserDefaults.standard
var deviceUUID = UIDevice.current.identifierForVendor!.uuidString
警告线是;
public var context = (UIApplication.shared.delegate as! AppDelegate).persistentContainer.viewContext
这样的另一个警告;
let parameters = [
"tel": "\(self.phone.text!)"
] as [String : String]
给予
UITextField.text 只能在主线程中使用
又是同样的错误..
我该如何解决?有什么想法吗?
【问题讨论】:
标签: appdelegate swift4 xcode9