0

Appleの例からコピー/貼り付けされたこのコードの何が問題になっていますか? ウィンドウ上にアラートがすぐに表示され、アプリケーションが (エラーなしで) 終了します。

    (NSApplicationTerminateReply)applicationShouldTerminate:(NSNotification *)notification {
     return NSTerminateCancel;
     if (registerModified){
     NSAlert *testAlert = [NSAlert alertWithMessageText:@"Voulez-vous enregister les modifications du registre?"
     defaultButton:@"Enregistrer"
     alternateButton:@"Ne pas enregistrer"
     otherButton:nil
     informativeTextWithFormat:@"Ces modifications seront permanentes."];

    [testAlert beginSheetModalForWindow:[self mainWindow]
     modalDelegate:self
     didEndSelector:@selector(alertDidEnd:returnCode:contextInfo:)
     contextInfo:nil];
    }


    - (void)alertDidEnd:(NSAlert *)alert returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo
    {
    #pragma unused (contextInfo)
    [[alert window] orderOut:self];
    }

beginSheetModalForWindow… 非常に高速な場合!

4

0 に答える 0