Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

xcode

ios

swift

Here's my code:

import UIKit

class ViewController: UIViewController {

    @IBOutlet var button: UIButton

    override func viewDidLoad() {
        super.viewDidLoad()
        // 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.
    }

}

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.

like image 751
josmek Avatar asked Jul 24 '14 19:07

josmek


1 Answers

It can also be-

    @IBOutlet var button: UIButton! 

or

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

if you are using XCODE 6 Beta 4

like image 167
Avi Avatar answered Oct 04 '22 04:10

Avi