Application is modifying the autolayout engine from a background thread Error
<p>Im not sure why but I have a button and textfield on my viewController,
the button is not visible when the view appears but when I click where the button should be it then appears. The pre-populated text in the text box also does not appear.</p>

<p>I am being presented with the following warning (im not sure if its related):</p>

<blockquote>
  <p>2016-12-30 11:25:26.030 wellpleased[5462:776953] This application is modifying the autolayout engine from a background thread after the engine was accessed from the main thread. This can lead to engine corruption and weird crashes.</p>
</blockquote>

<p>How would I prevent this warning and have the elements appear correctly?</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>class events: UIViewController, UITableViewDelegate, UITableViewDataSource {
    
    var rowID:String = ""
    var value:String!
    
    @IBOutlet var tableView: UITableView!
    var tableData: [String] = []
    var tableEventMonth: [String] = []
    var tableEventDay: [String] = []
    var tableEventCity: [String] = []
    var tableEventLink: [String] = []
    var tableEventID: [String] = []
    
    @IBOutlet weak var tableTopConstraint: NSLayoutConstraint!
    @IBOutlet weak var eventCodeView: UIView!
 
    @IBAction func addButton(_ sender: Any) {
 
            if self.eventCodeView.alpha == 1{
                
                
                self.view.layoutIfNeeded()
                UIView.animate(withDuration: 1, animations: {
                    self.view.layoutIfNeeded()
                    self.eventCodeView.alpha = 0
                    })
                
                
                
                self.tableTopConstraint.constant = 1
                UIView.animate(withDuration: 1) {
                    self.view.layoutIfNeeded()
                    
                }
            }else{
                
               
                self.view.layoutIfNeeded()
                UIView.animate(withDuration: 1, animations: {
                    self.view.layoutIfNeeded()
                    self.eventCodeView.alpha = 1
                    
                })
                
                
                
                self.tableTopConstraint.constant = 70
                UIView.animate(withDuration: 1) {
                    self.view.layoutIfNeeded()
                    }
        }
        
    }
    override func viewDidLoad() {
        super.viewDidLoad()
    
        let nib = UINib(nibName: "vwTblCell", bundle: nil)
        tableView.register(nib, forCellReuseIdentifier: "cell")
    
    }
    
    override func viewDidAppear(_ animated: Bool) {
        
         getTableData()
    }
    
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -&gt; Int {
        return self.tableData.count
    }
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -&gt; UITableViewCell  {
        let cell: TblCell = self.tableView.dequeueReusableCell(withIdentifier: "cell") as! TblCell

        cell.lblCarName.text = self.tableData[indexPath.row]
        cell.calendarDay.text = self.tableEventDay[indexPath.row]
        cell.calendarMonth.text = self.tableEventMonth[indexPath.row]
        cell.city.text = self.tableEventCity[indexPath.row]
        
        let defaults = UserDefaults()
        let event = defaults.string(forKey: "event")
        
        if self.tableData[indexPath.row] == event {
        cell.hereLabel.isHidden = false
        }
        
        return cell
    }
    
    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        print("Row \(indexPath.row) selected")
        
        rowID = tableEventID[indexPath.row]
        self.performSegue(withIdentifier: "goAttendees", sender: self)
        
    }
    
    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -&gt; CGFloat {
        return 90
    }

    func getTableData(){
        
        let defaults = UserDefaults()
        let userid = defaults.string(forKey: "id")
    
    let url = NSURL(string: "https://www.asmserver.co.uk/wellpleased/backend/eventselect.php?userid=\(userid!)")

        let task = URLSession.shared.dataTask(with: url as! URL) { (data, response, error) -&gt; Void in
           
            if let urlContent = data {
                
                do {
                    
                    if let jsonResult = try JSONSerialization.jsonObject(with: urlContent, options: []) as? [[String:AnyObject]] {
                        
                        
                        var i = 0
                        
                        while i &lt; jsonResult.count {
                            
                            
                            self.tableData.append(jsonResult[i]["eventname"]! as! String)
                            self.tableEventDay.append(jsonResult[i]["eventday"]! as! String)
                            self.tableEventMonth.append(jsonResult[i]["eventmonth"]! as! String)
                            self.tableEventCity.append(jsonResult[i]["city"]! as! String)
                            self.tableEventLink.append(jsonResult[i]["link"]! as! String)
                            self.tableEventID.append(jsonResult[i]["eventid"]! as! String)
                            

                            
                            
                            i = i + 1
                            
                        }
                        
                    }
                    
                } catch {
                    
                    print("JSON serialization failed")
                    
                }
                
            } else {
                
                print("ERROR FOUND HERE")
            }
            
            
            DispatchQueue.main.async(execute: { () -&gt; Void in
                
                self.tableView.reloadData()
                
            })
            
            self.tableView.isUserInteractionEnabled = true
        }
        
        task.resume()

            }

override func prepare(for segue: UIStoryboardSegue, sender: Any?){
    
    if(segue.identifier == "goAttendees") {
        
        let attendees = (segue.destination as! attendees)
        attendees.value = rowID
        
    }

  }

}</code></pre>
</div>
</div>
</p>