Swift 4 ,must be used from main thread only warning

Viewed 47743

When I using Swift4in Xcode 9 gives me

UIApplication.delegate must be used from main thread only

.... must be used from main thread only

UI API called from background thread Group

Purple Warning.

My codes;

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

Warning line is;

  public var context = (UIApplication.shared.delegate as! AppDelegate).persistentContainer.viewContext

Another warning like this;

 let parameters = [
                        "tel": "\(self.phone.text!)"
                        ] as [String : String]

Gives

UITextField.text must be used from main thread only

Same error again..

How can I fix it ? Any idea ?

1 Answers
Related