给控件绑定事件函数的时候,报错
在手动给控件添加事件的时候,报错
代码如下
class ViewController: UIViewController {
@IBOutlet weak var button: UIButton!
@IBOutlet weak var lable: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
button.addTarget(self, action: "buttonDown:", forControlEvents: .TouchDown)
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func buttonDown(sender:AnyObject)
{
lable.text = "哈哈哈,来个hellow,world"
}
}
报错如下
fatal error: unexpectedly found nil while unwrapping an Optional value
后来把控件都删除,重新拖一下就好了。。。。