Re: NSAlert Examples?
Re: NSAlert Examples?
- Subject: Re: NSAlert Examples?
- From: Ashley Clark <email@hidden>
- Date: Tue, 4 May 2004 20:03:33 -0500
On May 4, 2004, at 6:39 PM, Frederick C. Lee wrote:
>
Apple has supplied 'TextEdit' as an example of using Alerts.
>
Unfortunately, this is pre-Panther. According to the NSAlert doc:
>
...
>
"...The NSAlert class, which was introduced in Mac OS X v10.3,
>
supersedes the functional Application Kit API for displaying alerts
>
(NSRunAlertPanel, NSBeginAlertSheet, and so on). The former API is
>
still supported, but you are encouraged to use the NSAlert class for
>
your applications alert dialogs."
>
>
...
>
>
So I'm in the market for Panther+ NSAlert usages.
>
>
Does anyone know of any such references/examples?
Here's a simple example:
- (IBAction)testDatabaseConnection:(id)sender
{
NSAlert *alert = [[NSAlert alloc] init];
[alert setAlertStyle:NSInformationalAlertStyle];
[alert setMessageText:@"Successful Connection"];
[alert setInformativeText:@"This is a sheet detailing the
connection test status"];
[alert beginSheetModalForWindow:window
modalDelegate:self
didEndSelector:@selector(testDatabaseConnectionDidEnd:returnCode:
contextInfo:)
contextInfo:nil];
}
- (void)testDatabaseConnectionDidEnd:(NSAlert *)alert
returnCode:(int)returnCode contextInfo:(void *)contextInfo
{
NSLog(@"clicked %d button\n", returnCode);
[alert release];
}
That will display a sheet attached to the window and when a button is
clicked the didEndSelector is called. Examine the NSAlert class
documentation for other methods that can be used to modify its'
behavior.
Ashley Clark
[demime 0.98b removed an attachment of type application/pkcs7-signature which had a name of smime.p7s]
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.