NSAlert
Jump to navigation
Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
This article or section is a stub (i.e., in need of additional material). You can help us by expanding it |
---|
NSAlert is a modal dialog or sheet.
<syntaxhighlight lang="c_max">
/**
NS Alert Example*/
NSAlert* a = [ NSAlert alertWithMessageText:@"title" defaultButton:@"ok" alternateButton:@"cancel" otherButton:nil informativeTextWithFormat:@"more information ];
//Run as a dialog
NSInteger returnCode = [a runModal];
switch(returnCode)
{
case 1:
//ok
break;
case 2:
//cancel
break;
}
//Attach to window
[a beginSheetModalForWindow:windowP modalDelegate:self didEndSelector:@selector(alertDidEnd:) contextInfo:nil];
- (void) alertDidEnd:(NSAlert *)alert returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo
{
switch(returnCode)
{
case 1:
//ok
break;
case 2:
//cancel
break;
}
}
</syntaxhighlight>
See also