title: How to show a popup only once per day in Swift?
body: <p>I would like to show a popup only once per day in my app and if the user has already seen the popup, then, do not show it again for that day. I was struggling for a while and decided to ask for some help here :)</p>
  <p>Update</p>
  <p>Here is the code I have wrote so far:</p>
  <pre><code>func showPopupOncePerDay() -&gt; Bool {
      let lastPopup = UserDefaults.standard.double(forKey: &quot;lastPopup&quot;)
      let lastPopupDate = Date(timeIntervalSinceNow: lastPopup)
      let lastPopupIsToday = NSCalendar.current.isDateInToday(lastPopupDate)
      if !lastPopupIsToday {
          navigator.showAlertPopup()
      }
      UserDefaults.standard.set(Date().timeIntervalSince1970, forKey: &quot;lastPopup&quot;)
      return true
  }
  </code></pre>