I have an app that has tableview. The content of tableView is like twitter/instagram is fetch from EndPoint A,for example. While there are button follow/unfollow that need to fetch the status from Endpoint B.
I already tried to call the EndPoint B from every cell but i think because the asynchronous, the status is shown on random cell.
How do i get to fetch the status that has different endpoint while keep my apps smooth?
Here's the code that i've used:
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let checkStatus = self.getFollowStatus(userID: id)
    if (checkStatus) {
         cell.followButton.setTitle("Unfollow", for: UIControlState.normal)
    } else {
         cell.followButton.setTitle("Follow", for: UIControlState.normal)
    }
  //rest the code
}
  func getFollowStatus(userID:String) -> Bool {
    Alamofire.request(url, method: .get, parameters: nil, headers:headers)
        .responseJSON {response in
            if let result = response.result.value {
                let JSON = result as! NSDictionary
                if let data = JSON["data"] as? [String: Any]{
                    let status = data["follow_status"] as! String
                    if status == "follow" {
                        self.isFollow = true
                    } else {
                         self.isFollow = false
                    }
                }
            }
    return self.isFollow
}
Thanks..
