josmek josmek - 2 years ago 128
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
Answer Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download