josmek josmek - 4 months ago 5x
iOS Question

'IBOutlet' property has non-optional type 'UIButton'

Here's my code:

import UIKit

class ViewController: UIViewController {

@IBOutlet var button: UIButton

override func viewDidLoad() {
// Do any additional setup after loading the view, typically from a nib.

override func didReceiveMemoryWarning() {
// Dispose of any resources that can be recreated.


It's a simple IBOutlet (straight from the Apple developer docs). It gives me the error "'IBOutlet' property has non-optional type 'UIButton'" and I have no idea how to fix it.

Avi Avi

It can also be-

    @IBOutlet var button: UIButton! 


    @IBOutlet var weak button: UIButton! (in case you are not doing view unloading)

if you are using XCODE 6 Beta 4