macosnsdocumentnssavepanel

Strange Bug:thanks, but I need to control my own subviews


2014-11-08 17:24:46.487 Intelligent Notes[4472:303] APP-reportExceptionthanks, but I need to control my own subviews
2014-11-08 17:24:46.488 Intelligent Notes[4472:303] thanks, but I need to control my own subviews
2014-11-08 17:24:46.494 Intelligent Notes[4472:303] (
    0   CoreFoundation                      0x00007fff8742b25c __exceptionPreprocess + 172
    1   libobjc.A.dylib                     0x00007fff86b0fe75 objc_exception_throw + 43
    2   CoreFoundation                      0x00007fff8742b10c +[NSException raise:format:] + 204
    3   ViewBridge                          0x00007fff8691d9a8 -[NSRemoteView addSubview:] + 70
    4   Intelligent Notes                   0x000000010001aa2c -[Document(TextEditNSDocumentOverrides) prepareSavePanel:] + 2380

Sometime I get this strange log when I add a button at NSDocument's savePanel to close app after save operation end. This log surprise me! How can I solve it? Or How can I use cocoa’s save panel for have a @"Don't Save" button?

- (BOOL)prepareSavePanel:(NSSavePanel *)savePanel {
    if (self.noNeedSave) {
        NSButton * aBtn = [NSButton new];
        [aBtn setButtonType:NSMomentaryLightButton];
        [aBtn setBezelStyle:NSRoundedBezelStyle];
        [aBtn setFrame:NSMakeRect(40, 10, 100, 24)];
        [aBtn setAction:@selector(closeWindowNoSave)];
        [aBtn setTarget:self];
        [aBtn setTitle:@"Don't Save"];
        [aBtn setAlignment:NSCenterTextAlignment];
        [savePanel.contentView addSubview:aBtn];
    }
    return YES;
}

Solution

  • Finally I found the "Don't Save" button of save panel of document. Change the action to use my method for close window and don't save.