“uppercaseString” and “lowercaseString” on UITextField crash in Swift

后端 未结 1 1701
旧时难觅i
旧时难觅i 2021-01-21 15:39

I have a small application which has 1 ViewController with: 2 Outlets (one UITextField and one UILabel) and 1 Action that is triggered whe

相关标签:
1条回答
  • 2021-01-21 16:15

    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
        }
    
    }
    

    enter image description here

    enter image description here

    sample

    0 讨论(0)
提交回复
热议问题