TableView.reloadData() is not working ? (SWIFT)

前端 未结 3 634
失恋的感觉
失恋的感觉 2021-01-24 10:09

I am developing a Quiz App which fetches questions from a JSON. I have already used reloadData for TableView many times & worked as expected. But now I am fetching Questions

3条回答
  •  隐瞒了意图╮
    2021-01-24 11:09

    Use dispatch queue to call your completion handler in .responseJSON , and from there update your UI .

    E.G.

    Alamofire.request(.GET, postEndpoint, headers: headers)
            .responseJSON { response in 
    
        // Do something...
    
        dispatch_async(dispatch_get_main_queue(), {
            // Update your UI here
            self.tableView.reloadData()
         })
    }
    

提交回复
热议问题