Guest User

Untitled

a guest
Jun 25th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.04 KB | None | 0 0
  1. func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
  2.  
  3. let cell2 = collectionV.dequeueReusableCell(withReuseIdentifier: cellIdentifier, for: indexPath) as! SelectFriendCollectionViewCell
  4. let cell5 = self.collectionV.cellForItem(at: indexPath) as? SelectFriendCollectionViewCell
  5. let Friends_avatarname = (cell5?.avatarUsername_Outlet.text! as? String!)!
  6. let Friends_UID = (cell5?.avatarUID_Outlet.text! as? String!)!
  7.  
  8.  
  9. let Friend = FriendsSelectArray(avatarUID: (Friends_UID as! String?)!, avatarname: (Friends_avatarname as! String?)!)
  10. self.FriendsSelect.append(Friend)
  11. print ("Friend added :(Friend.avatarname)")
  12.  
  13. }
  14.  
  15. func collectionView(_ collectionView: UICollectionView, didDeselectItemAt indexPath: IndexPath) {
  16.  
  17. let cell2 = collectionV.dequeueReusableCell(withReuseIdentifier: cellIdentifier, for: indexPath) as! SelectFriendCollectionViewCell
  18. let cell5 = self.collectionV.cellForItem(at: indexPath) as? SelectFriendCollectionViewCell
  19.  
  20.  
  21. let Friends_avatarname = (cell5?.avatarUsername_Outlet.text! as? String!)!
  22. let Friends_UID = (cell5?.avatarUID_Outlet.text! as? String!)!
  23. var Friend = FriendsSelectArray(avatarUID: (Friends_UID as! String?)!, avatarname: (Friends_avatarname as! String?)!)
  24.  
  25. }
  26.  
  27. class FriendsSelectArray{
  28. var avatarUID: String
  29. var avatarname: String
  30.  
  31.  
  32. init( avatarUID: String, avatarname: String){
  33. self.avatarUID = avatarUID
  34. self.avatarname = avatarname
  35.  
  36. }
  37. func returnPostAsDictionary()->NSDictionary{
  38. let postDictionary: NSDictionary = ["avatarUID": avatarUID,
  39. "avatarname": avatarname]
  40. return postDictionary
  41. }
  42. }
  43.  
  44. class SelectFriendViewController: UIViewController, UICollectionViewDataSource, UICollectionViewDelegate {
  45.  
  46. @IBOutlet weak var collectionV: UICollectionView!
  47.  
  48. var databaseRef: DatabaseReference!
  49. let cellIdentifier = "cell"
  50. var FriendsSelect : [FriendsSelectArray] = []
  51. var selectedCell = [IndexPath]()
Add Comment
Please, Sign In to add comment