Here\'s the code:
- (IBAction) charlieInputText:(id)sender {
//getting value from text field when entered
charlieInputSelf = [sender stringValue];
-(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];
}
}