Objective c checking whether text field is empty

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

    -(void)insert{
    
        if ([_nameofView  isEqual: @""]) {
            UIAlertController* alert = [UIAlertController alertControllerWithTitle:@"Alert"
                                                                           message:@"Fill the Name Field First."
                                                                    preferredStyle:UIAlertControllerStyleAlert];
    
            UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault
                                                                  handler:^(UIAlertAction * action) {}];
    
            [alert addAction:defaultAction];
            [self presentViewController:alert animated:YES completion:nil];
    
    
    
        }
        else if ([_detailofview  isEqual: @""]){
    
            UIAlertController* alert = [UIAlertController alertControllerWithTitle:@"Alert"
                                                                           message:@"Fill the Details Field First."
                                                                    preferredStyle:UIAlertControllerStyleAlert];
    
            UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault
                                                                  handler:^(UIAlertAction * action) {}];
    
            [alert addAction:defaultAction];
            [self presentViewController:alert animated:YES completion:nil];
    
        }
        else{
            UIAlertController* alert = [UIAlertController alertControllerWithTitle:@"Alert"
                                                                           message:@"Data Inserted Successfully."
                                                                    preferredStyle:UIAlertControllerStyleAlert];
    
            UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault
                                                                  handler:^(UIAlertAction * action) {}];
    
            [alert addAction:defaultAction];
            [self presentViewController:alert animated:YES completion:nil];
    
        }
    }
    

提交回复
热议问题