NSAlert beginSheetModalForWindow
is for Mac OS development.
As you mentioned iPhone
as a tag to this question, I assume you are developing iOS application. For iOS development, use UIAlertController
. Here is the sample code:
UIAlertController * alert = [UIAlertController alertControllerWithTitle:@"Title" message:@"Message" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* yesButton = [UIAlertAction
actionWithTitle:@"Yes"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
//Handel yes button action here
}];
UIAlertAction* noButton = [UIAlertAction
actionWithTitle:@"No"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
//Handel no button action here
}];
[alert addAction:yesButton];
[alert addAction:noButton];
[self presentViewController:alert animated:YES completion:nil];
For more details, refer Apple iOS Documentation
Hope this helps.