Search code examples
swiftimportclassnotfound

"class not found" shows up even though I did it before In another viewController but it doesn't work


I get this message and a lot of the time I am following a tutorial and it is the exact same code yet it says it is wrong then I turn off my computer and it fixes itself, is this normal? my issue right now is that it "class not found"

I also move my file to use MVC but then it doesn't let me import UIKit and I have to remove it from the folder and then it worksenter image description here


Solution

  • Try change:

    var color2: UIColor -> color2: UIColor?

    Because your variable color2 is not optional, you need init it before. So set it optional or set a default value for it.