1

I'm new to Cocoa, xcode.I'm Doing Sample Project " How to display AlertPanel and Alert Sheets.I am Getting Error Like this "thread1:EXC_BAD_INSTRUCTION(code=EXC_1386_INVOP,subcode=...).Here i Mentioned the Code line where i got the error.Please help me out.

Alert.beginSheetModalForWindow(window,completionhandler:{(code:NSMOdalResponse)-> void in.
Mrunal
  • 13,982
  • 6
  • 52
  • 96
k.hema
  • 35
  • 5

1 Answers1

0

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.

Community
  • 1
  • 1
Mrunal
  • 13,982
  • 6
  • 52
  • 96
  • sorry ,unfortunately i tagged iphone,actually i am creating sample project for mac os and using the Xcode(7.3.1) IDE.please help me. – k.hema Jun 06 '16 at 04:43