Reputation: 27
I have a small application which has 1 ViewController
with: 2 Outlets (one UITextField
and one UILabel
) and 1 Action that is triggered when a button is pressed. The code looks like this:
class ViewController: UIViewController {
@IBOutlet weak var textField: UITextField!
@IBOutlet weak var label: UILabel!
@IBAction func changeText() {
label.text = textField.text.lowercaseString
}
}
My questions is why every time I run the app and press the button, the app crashes with EXC_BAD_ACCESS
?
EDIT 1: It seems that Xcode is the problem. I crashes only on Xcode 6.3 beta, on 6.1.1 it works fine. Here is the project LINK
EDIT 2: Problem SOLVED, Xcode version was the problem, thank you all for your answers!
Upvotes: 2
Views: 426
Reputation: 236305
This is a known issue with beta 1 and it has being fixed. You are using a button to update the label field but there is no need to use a button for that. You can choose to connect your IBAction to your text Field's Sent Events Editing Changed to make it change with a real time as you type preview.
Swift Compiler • @objc enums no longer cause the compiler to crash when used from another file. (19775284) • Fixed a use after free crash in lowercaseString and uppercaseString. (19801253)
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var label: UILabel!
@IBOutlet weak var textField: UITextField!
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.
}
@IBAction func changeText(sender: AnyObject) {
label.text = textField.text.lowercaseString
}
}
Upvotes: 1