Objective c checking whether text field is empty

后端 未结 8 1168
孤独总比滥情好
孤独总比滥情好 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:21

    We already have inbuilt method that return boolean value that indicates whether the text-entry objects has any text or not.

    // In Obj-C
    if ([textField hasText]) {
            //*    Do Something you have text
        }else{
             /* what ever */
        }
    
    // In Swift
    
    if textField.hasText {
        //*    Do Something you have text
    }else{
         /* what ever */
    }
    

提交回复
热议问题