title: How can prepareForReuse() be implemented to prevent a faded cell from acting weird?
body: <p>I use self.like.alpha = 0.5 to highlight the . like button next to the user who was liked. Scrolling causes the highlight to sometimes disappear and appear next to other users. </p>
  
  <p>I have figured out that I can either use A) prepareForReuse or B) do something like this pseudocode (although IsLiked would have to be confined to that session somehow) : </p>
  
  <pre><code>cell.like.alpha = item.isLiked ? 0.5 : 1
  </code></pre>
  
  <p>Here is my code:</p>
  
  <p>In View ControllerTableViewCell.swift:</p>
  
  <pre><code> @IBAction func likePressed(_ sender: Any) {
  
   self.like.alpha = 0.5
     let ref = Database.database().reference()
  let keyToPost = ref.child("likes").childByAutoId().key
  
  ref.child("humans").child(self.postID).observeSingleEvent(of: .value, with:  {(snapshot) in
  
      if let humans = snapshot.value as? [String: AnyObject] {
          let updateLikes: [String: Any] = ["humansWhoLike/\(keyToPost)" : Auth.auth().currentUser!.uid]
  
          ref.child("humans").child(self.postID).updateChildValues(updateLikes, withCompletionBlock: { (error, reff) in
  
              if error == nil {
                  ref.child("humans").child(self.postID).observeSingleEvent(of: .value, with: { (snap) in
                      if let properties = snap.value as?[String: AnyObject]{
                          if let likes = properties["humansWhoLike"] as? [String : AnyObject] {
                              let count = likes.count
                          let update = ["likes" : count]
                              ref.child("humans").child(self.postID).updateChildValues(update)
  
                          }
                      }
                  })
              }
          })
      }
  })
  ref.removeAllObservers()
   }
  </code></pre>
  
  <p>In homepage.swift(where like button is used):</p>
  
  <pre><code>public override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -&gt; UITableViewCell {
  let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! ViewControllerTableViewCell
  
  let like = cell.viewWithTag(3) as! UIButton
  
  
  let immy = cell.viewWithTag(1) as! UIImageView
  
  let person: Userx = humans[indexPath.row]
  
  cell.lblName.text = person.Education
  
  cell.postID = self.humans[indexPath.row].postID
  
  if let PhotoPosts = person.PhotoPosts {
      let url = URL(string: PhotoPosts)
      immy.sd_setImage(with: url)
  }
  return cell
  }
  </code></pre>
  
  <p>I need the like fade to not go away and not go to other users when cells get reused after scrolling.</p>
  
  <p>Database Structure:</p>
  
  <pre><code> "humans" : {
  "5VbL3Adj7teM2KNJkF4GIexBJhE2" : {
    "Coordinates" : {
      "latitude" : 42.8864,
      "longitude" : 78.8784
    },
    "Education" : "Yale Accounting",
    "PhotoPosts" : "https://firebasestorage.googleapis.com/v0/b/daylike-2f938.appspot.com/o/images%2FPhotoPosts?alt=media&amp;token=42d76567-ac42-4728-9914-1d7c2fa4d5e6",
    "WhatIamConsideringBuying" : "Twitter: Carla9",
    "caption" : 1565896677651,
    "caption1" : {
      "caption1" : 1566734644170,
      "keyToPost" : "-Ln7eM9S_pSQ_aqRPz0k"
    },
    "likes" : 82,
    "peopleWhoLike" : {
      "-LmLjHwwGj1kt5qLM20X" : "NMNQYJ5z64fATK2MMs7m0ggHl0k2",
      "-LmLtlp5Sm900SV8xP4i" : "NMNQYJ5z64fATK2MMs7m0ggHl0k2",
      "-LmLuOzQ0TZ9uJ_uNkkg" : "NMNQYJ5z64fATK2MMs7m0ggHl0k2",
      "-LmLultcrrsG2NjEYoTe" : "NMNQYJ5z64fATK2MMs7m0ggHl0k2",
      "-LmLvMseSmFhnxEGGctU" : "NMNQYJ5z64fATK2MMs7m0ggHl0k2",
      "-LmLvVQokDCZLFrnhaLu" : "NMNQYJ5z64fATK2MMs7m0ggHl0k2",
  
    },
    "postID" : "5VbL3Adj7teM2KNJkF4GIexBJhE2",
    "users" : "carla19martin@me.com"
  },
  "9RYUttVhCzXKs6H1XnZ63TZ8Dun2" : {
  </code></pre>