In Swift
let alertController = UIAlertController(title:"Title", message: "Message", preferredStyle:.alert)
let Action = UIAlertAction.init(title: "Ok", style: .default) { (UIAlertAction) in
// Write Your code Here
}
alertController.addAction(Action)
self.present(alertController, animated: true, completion: nil)
In Objective C
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Title" message:@"Message" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *OK = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action)
{
}];
[alertController addAction:OK];
[self presentViewController:alertController animated:YES completion:nil];