Combine two tutorials / Chat&Timer / Match two Users randomly

Hey everyone, i’m really happy that i found this awesome website.
I followed most of the tutorials here and tried to mix them up to get an app that does the following:

  1. Secretly User Authentication
  2. Open Chat via JSQMessenger
  3. Match 2 random users who both pressed a button
  4. Start Countdown
  5. End Chat after 30 sec
  6. Alert-like notification that the chat ended
  7. Possibility to save chatlog (maybe in sceenshots)

I started with the ChatChat app, which works great. Firebase is set up and user communication is stored as in the tutorial. The timerapp was the next thing, i tried to use the NSTimer and an alert. I called the startTimer() function in logInDidTouch, works up to the point where the alert should be displayed. After the countdown stopps, the following error appears:

ChatChat[15699:429353] Warning: Attempt to present <UIAlertController: 0x7fb740620290> on <ChatChat.LoginViewController: 0x7fb740442f00> whose view is not in the window hierarchy!

As i am new to iOS development, i dont really know how i can add the view to the window hierarchy - any ideas?

Next thing is, i want to match two users, that are in queue for chat.
User one -> Button “start chat”
User two -> Button “start chat”

If it is now the case that two users, at the same time, want to chat, they get randomly matched and can have a conversation for an amount of time until the timer runs out, alert appears and you go back to the login screen.

Is there anyone that has an idea or advice on this?
Thanks guys, appreciating it!

Leon

Sounds pretty cool - speed dating app?

Where are you trying to present the alert controller? If you do it before a view controller’s viewDidAppear method is called the hierarchy doesn’t really exist at that point, and you will see that error message. If you are doing this, then you must present the alert on a view that is currently displayed. Perhaps you have pushed (presented) another view controller and you should be presenting from that view controller, not LoginViewController?