Unexpectedly found nil while unwrapping an Optional value , but print message says it has a value

I am following a youtube tutorial and replacing the content to fit my firebase database for the project but I can't figure out why I am getting "Unexpectedly found nil while unwrapping an Optional value" error at this point.
I have bolded the line where the error occurs, and as you can see I have a print statement right above it, and this produces the desired results so its not NIL but why is this message coming?

import UIKit
import Firebase

class firstViewViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {

@IBOutlet weak var tableViewer: UITableView!

var refPlayer = DatabaseReference()
var playerList = [PlayerModel]()

 func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    return  playerList.count

 func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let cell = tableViewer.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! labelviewCell
    let player: PlayerModel
    player = playerList[indexPath.row]
    **cell.labelOne.text = player.navn**. // HERE IS THE ERROR

    return cell

override func viewDidLoad() {
    refPlayer = Database.database().reference().child("Player");
    refPlayer.observe(DataEventType.value, with: {(snapshot) in
        if snapshot.childrenCount > 0 {
            for players in snapshot.children.allObjects as! [DataSnapshot]{
                let playerOject = players.value as? [String: AnyObject]
              //  let playerId = playerOject?["id"]
                let playerName = playerOject?["navn"]
                let playerweek = playerOject?["uke"]
              // let playerPlayed = playerOject?["spillet"]
               // let playerExtra = playerOject?["extra"]
             //   let playerWalkover = playerOject?["walkover"]
             //   let playerKommentar = playerOject?["kommentar"]
                let player = PlayerModel(//id: playerId as! String,
                                         navn: (playerName as! String?)!,
                                         uke: (playerweek as! String?)!
                                       //  spillet: (playerPlayed as! String?)!,
                                      //   extra : (playerExtra as! String?)!,
                                      //   walkover: (playerWalkover as! String?)!,
                                      //   kommentar: (playerKommentar as! String?)!
override func didReceiveMemoryWarning() {
    // Dispose of any resources that can be recreated.


Hi Malik,

This forum is focused on the Swift language and related projects. For iOS questions, you can use Stack Overflow or the Apple Developer Forums.

That being said, my guess would be you didn't hook up the labelOne outlet in your labelviewCell.

you are absolutely right! thank you very much :slight_smile: