uialertcontroller example objective c

Sure! Here's an example of how to use UIAlertController in Objective-C:

UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Title"
                                                                         message:@"Message"
                                                                  preferredStyle:UIAlertControllerStyleAlert];

UIAlertAction *action = [UIAlertAction actionWithTitle:@"OK"
                                                 style:UIAlertActionStyleDefault
                                               handler:^(UIAlertAction * _Nonnull action) {
                                                   // Add your code here for handling the OK button tap
                                               }];

[alertController addAction:action];

// Present the alert controller
[self presentViewController:alertController animated:YES completion:nil];

This code creates an instance of UIAlertController with a title, message, and style. It then adds an UIAlertAction for the OK button with a handler block that will be executed when the button is tapped. Finally, it presents the UIAlertController using the presentViewController:animated:completion: method.

Please note that this code assumes you are using it within a view controller. If you are using it in a different context, you may need to adjust the code accordingly.