alertWithError:
エラーオブジェクトでアラートオブジェクトを作って返します
+(NSAlert *)alertWithError:(NSError *)anError:
init(error error: NSError) -> NSAlert
フレームワーク
ApplicationKit
クラス
NSAlert
使用可能
10.4
編集時のバージョン
OS X 10.10
参照
例文
#import "MyObject.h" @implementation MyObject - (IBAction)myAction:(id)sender { NSError *error = [NSError errorWithDomain:@"NSOSStatusErrorDomain" code:-10 userInfo:[NSDictionary dictionary] ]; NSAlert *alert = [NSAlert alertWithError:error]; //表示します、 [alert beginSheetModalForWindow:[sender window] modalDelegate:self didEndSelector:@selector(endAlert) contextInfo:nil ]; } //閉じる時の処理 -(void)endAlert { NSLog(@"end"); } @end
//NSApplication alertWithError @IBAction func function002(sender: AnyObject) { //なにかモーダルがあっても終わり NSApp.abortModal() var anError: NSError? = NSError(domain: NSMachErrorDomain, code: -1, userInfo: nil) //NSAlertの作成 let anAlert:NSAlert = NSAlert(error: anError!) let response:Int = anAlert.runModal() }