fatal error: unexpectedly found nil while unwrapping an Optional value - why?

后端 未结 1 1144
无人及你
无人及你 2020-12-22 07:16

I\'m pretty new to coding in Swift and I\'m not too sure what\'s happening here - can anyone help?

Thanks

import UIKit

class SecondViewController: U         


        
相关标签:
1条回答
  • 2020-12-22 07:33

    Most likely, your IBOutlet, toDoItem, was not bound successfully to a UITextField in Interface Builder. Check the outlets for your text field in Interface Builder and make sure it's hooked up successfully.

    enter image description here

    If the outlet is hooked up properly, another candidate source of this problem is the instantiation of the view controller itself. If you instantiated it programmatically (e.g. SecondViewController() instead of storyboard.instantiateViewControllerWithIdentifier(...)), that would also result in this error.

    0 讨论(0)
提交回复
热议问题