Skip to content

Instantly share code, notes, and snippets.

@zontan
Created July 6, 2020 22:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zontan/549a74b8a34a95010e300f025d4a50a7 to your computer and use it in GitHub Desktop.
Save zontan/549a74b8a34a95010e300f025d4a50a7 to your computer and use it in GitHub Desktop.
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return resultsArray.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "userCell", for: indexPath)
if let userCell = cell as? UserTableViewCell {
let uid = resultsArray[indexPath.row]
userRef.child(uid).child("displayname").observeSingleEvent(of: .value) { (snapshot) in
userCell.displayName.text = snapshot.value as? String
}
}
return cell
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let uid = resultsArray[indexPath.row]
delegate?.didJoinFriend(uid: uid)
self.dismiss(animated: true, completion: nil)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment