 
         return cell
     }
+    
+    func presentAlert(title: String, message: String) -> Void {
+        let alert = UIAlertController(title: title, message: message, preferredStyle: UIAlertControllerStyle.alert)
+        alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.default, handler: nil))
+        self.present(alert, animated: true, completion: nil)
+    }
 
 
     override func didReceiveMemoryWarning() {

                    let userItem = User(snapshot: user as! FIRDataSnapshot)
                    
                    if textField.text! == userItem.email {
                        
                        // TODO: Gevonden!
                        // Stuur naar userItem naar iets
                        print("Gevonden: \(userItem.email)")
                        completion(true, userItem)
                        return
                    }
                }
                
                completion(false, nil)
            })
            
            
            // users ophalen en checken op email
            // als user bestaat; toevoegen
            // anders foutmelding
            
        })
        
        let cancelAction = UIAlertAction(title: "Cancel", style: .default, handler: {

    @IBAction func inviteButtonDidTouch(_ sender: UIButton) {
        
        showAlertControllerWith { (succeed, user) in
            if succeed {
                if let user = user {
                    
                    print("Gelukt!! UID buddy: \(user.uid)")
                    
                    // Add UID buddy to travel-item.
                    self.travelRef.observe(.value, with: { snapshot in
                        for item in snapshot.children {
                            let travelItem = Travel(snapshot: item as! FIRDataSnapshot)
                            
                            if travelItem.travelId == self.travelId {
                                // user.uid toevoegen.. HOE!?
                            }
                        }
                    })
                }
                
            }
            else {
                print("Er is iets fout gegaan!")
                
                self.presentAlert(title: "Oops!", message: "Your buddy does not use Adventure Time yet.")
                
//                let alert = UIAlertController(title: "Oops!", message: "Your buddy does not use Adventure Time yet.", preferredStyle: UIAlertControllerStyle.alert)
//                alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.default, handler: nil))
//                self.present(alert, animated: true, completion: nil)
            }
            
        }
