Objective c checking whether text field is empty

后端 未结 8 1185
孤独总比滥情好
孤独总比滥情好 2021-02-05 01:11

Here\'s the code:

- (IBAction) charlieInputText:(id)sender {
    //getting value from text field when entered
    charlieInputSelf = [sender stringValue];

           


        
8条回答
  •  天涯浪人
    2021-02-05 01:34

    Check whether text field is empty in Swift

      @IBOutlet weak var textField: NSTextField!
      @IBOutlet weak var multiLineTextField: NSTextField!
    
      @IBAction func textChanged(sender: AnyObject) {
        //println("text changed! \(textField.stringValue)")
    
        if textField.stringValue.isEmpty == false {
          multiLineTextField.becomeFirstResponder()
          multiLineTextField.editable = true
        } else {
          multiLineTextField.editable = false
        }
      }
    

提交回复
热议问题