I have been following the Apple tutorial to getting started with Swift here: https://developer.apple.com/library/ios/referencelibrary/GettingStarted/DevelopiOSAppsSwift/Lesson3.html#//apple_ref/doc/uid/TP40015214-CH22-SW1
I'm doing almost the same thing but for some reason articleLink.delegate = self
is giving me
Thread 1: exc_bad_instruction (code=exc_i386_invop subcode=0x0)
and
fatal error: unexpectedly found nil while unwrapping an Optional value
I'm really confused about why this is happening because I'm literally following the Apple tutorial step by step for this part...
import UIKit
import Alamofire
class ViewController: UIViewController, UITextFieldDelegate {
// MARK: Properties
@IBOutlet weak var articleLink: UITextField!
override func viewDidLoad() {
super.viewDidLoad()
// Handle the text field's user input through delegate callbacks
articleLink.delegate = self // ERROR OCCURS HERE
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
// MARK: UITextFieldDelegate
func textFieldShouldReturn(textField: UITextField) -> Bool {
// Hide keyboard
textField.resignFirstResponder()
return true
}
// MARK: Actions
@IBAction func submitLink(sender: AnyObject) {
}
}