1

I'm new to Swift so if this is a basic question don't burn me at the stake. Before I start, I'd like to say I am running a virtual machine (hackintosh) on windows 10, using Mac OS X Sierra.

The project is a page-based application on Xcode 8. Even without adding code at all, just label text w/o actions or outlets, and trying to run the code, gives me an error.

The code w/ the error:

import UIKit

class DataViewController: UIViewController {
    @IBOutlet weak var dataLabel: UILabel!
    var dataObject: String = ""

    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        self.dataLabel!.text = dataObject; // error here
    }
}

enter image description here

Been stuck on this and can't find much.

rmaddy
  • 314,917
  • 42
  • 532
  • 579
  • 1
    This has been asked and answered a million times but oddly I can't find a good duplicate. You never connected your `dataLabel` outlet so it's `nil`. And you are force unwrapping the `nil` pointer. That's bad. – rmaddy Dec 19 '16 at 00:18
  • @rmaddy please post an answer on how to fix so i can mark as answer – Xena OS Development Team Dec 19 '16 at 00:21

0 Answers0