• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSAlert?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSAlert?


  • Subject: Re: NSAlert?
  • From: Pierce Freeman <email@hidden>
  • Date: Sat, 18 Oct 2008 12:43:00 -0700
  • Thread-topic: NSAlert?

Thanks for your help.  However, Xcode gives me this warning when I build:

 NSAlert' may not respond to
'+alertWithMessageText:defaultButton:aleternateButton:otherButton:informativ
eTextWithFormat:'


Sincerely,

Pierce F.



On 10/18/08 12:26 PM, "Jason Coco" <email@hidden> wrote:

>
> On Oct 18, 2008, at 14:35 , Pierce Freeman wrote:
>
>> Hi everyone.
>>
>> I have been attempting to create a NSAlert popup and get the result
>> (so it
>> can run an if statement) for the last few hours, but I still can't
>> get it to
>> work.  My current code is below, if anyone wants to have a look
>> see... If
>> anyone could point me in the right direction, it would be much
>> appreciated!
>
> the runModal message blocks until the alert is cleared and then
> returns the code
> directly. If you want the alert message to be async, you should send
> the beginSheetModalForWindow
> message (see the NSAlert documentation...)
>
> To make your code work, simply do something like this:
>
> if( [askToContinue runModal] != NSAlertDefaultReturn ) {
> // do something interesting...
> }
>
>> Sincerely,
>>
>> Pierce F.
>>
>>
>> -- Code --
>>
>> -(void)someFunction
>> {
>> NSAlert * askToContinue = [NSAlert alertWithMessageText:@"Message"
>> defaultButton:@"Button 1"
>>
>> aleternateButton:@"Button 2"
>>                                                     otherButton:nil
>>                                informativeTextWithFormat:@"Message to
>> User"];
>>
>>
>>            [askToContinue runModal];
>> }
>>
>>
>>
>> - (void)alertEnded:(NSAlert *)alert
>>              code:(int)choice
>>           context:(void *)inContextOfItem
>> {
>>    if (choice != NSAlertDefaultReturn)
>>    {
>>        // Do something
>>    }
>>
>> }
>>
>>
>>
>> -- End Code --
>>
>>
>> _______________________________________________
>>
>> Cocoa-dev mailing list (email@hidden)
>>
>> Please do not post admin requests or moderator comments to the list.
>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>>
>> Help/Unsubscribe/Update your Subscription:
>> @gmail.com
>>
>> This email sent to email@hidden
>


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: NSAlert?
      • From: Jason Coco <email@hidden>
References: 
 >Re: NSAlert? (From: Jason Coco <email@hidden>)

  • Prev by Date: Re: NSAlert?
  • Next by Date: Re: NSAlert?
  • Previous by thread: Re: NSAlert?
  • Next by thread: Re: NSAlert?
  • Index(es):
    • Date
    • Thread