title: Why does my User Defaults bool not set on first launch of app?
body: <p>I have a <code>UserDefault</code> <code>Bool</code> for music playing. </p>
  
  <p>When launched for the first time, I attempt to set the bool to true, like this...</p>
  
  <pre><code>if launchedBefore {
  
          // Do nothing.
  
      } else {
  
          UserDefaults.standard.set(true, forKey: "musicOn")
          print("music is \(musicOn)")
          UserDefaults.standard.set(true, forKey: "alreadylaunched")
  
      }
  </code></pre>
  
  <p>This is in <code>viewDidAppear()</code>.</p>
  
  <p>The problem is that it does not set as true on the first launch, regardless of where I set the bool, it could be without the <code>launchedBefore</code> check, it still does not set on the first time.</p>
  
  <p>I don't see why this wouldn't work? musicOn is equal to false always on first launch, then on second launch, it is true?</p>
  
  <p>Any insight would be appreciated. Thanks!</p>