title: Why is this Label not showing the correct value? Swift
body: <p>I wrote a code to take data from my CoreDate Entity to show the highest Integer as the value at a Highscore label. I don't understand why it is not working? I tried it with or without a extra function...</p>
  <pre><code>func loadHighscore() {
          
          //Kontext identifizieren
          guard let appDelegate = UIApplication.shared.delegate as? AppDelegate else {
              return
          }
          
          //Anfrage stellen
          let context = appDelegate.persistentContainer.viewContext
          let entityName = &quot;PushUps&quot;
          
          let request = NSFetchRequest&lt;NSFetchRequestResult&gt;(entityName: entityName)
          
          do {
              let results = try context.fetch(request)
              for result in results {
              
                  guard let count = (result as! NSManagedObject).value(forKey: &quot;highScore&quot;) as? Int16 else {
                          return
          
                      }
              }
                  if count &gt; highScore {
                      highscoreLabel.text = &quot;Highscore: \(count)&quot;
                      highScoreChanged(newHighScore: Int16(count))
                      // Console statement:
                      print(&quot;New Highscore: \(count)&quot;)
                  }
              } catch {
                  print(&quot;error&quot;)
              }
          
      }
      
      
      func highScoreChanged(newHighScore: Int16) {
          highscoreLabel.text = &quot;Highscore: \(newHighScore)&quot;
      }
      
      
      
      
  }
  
  </code></pre>