0

我从“命令行工具”模板在 XCode 中创建了一个项目。

这会像您预期的那样运行,在屏幕的左下角创建一个蓝色的 200px 窗口。

#import <Cocoa/Cocoa.h>

int main(int argc, const char * argv[]) {
    NSRect frame = NSMakeRect(0, 0, 200, 200);
    NSWindow* window  = [[NSWindow alloc] initWithContentRect:frame
                                                     styleMask:NSTitledWindowMask
                                                       backing:NSBackingStoreBuffered
                                                         defer:NO];
    [window setBackgroundColor:[NSColor blueColor]];
    [window makeKeyAndOrderFront:NSApp];

    CFRunLoopRun();
    return 0;
}

但是,如果我将 更改styleMaskNSBorderlessWindowMask,它会开始抛出此错误:

May 22 22:54:35 Pros-MacBook-Kevin.local createwindow[2133] <Warning>: CGSConnectionByID: 0 is not a valid connection ID.
May 22 22:54:35 Pros-MacBook-Kevin.local createwindow[2133] <Warning>: Invalid Connection ID 0
2015-05-22 22:54:35.569 createwindow[2133:74617] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Error (1000) creating CGSWindow'
*** First throw call stack:
(
    0   CoreFoundation                      0x00007fff873dc03c __exceptionPreprocess + 172
    1   libobjc.A.dylib                     0x00007fff8767976e objc_exception_throw + 43
    2   CoreFoundation                      0x00007fff873dbeed +[NSException raise:format:] + 205
    3   AppKit                              0x00007fff87e15306 _NXCreateWindowWithStyleMask + 457
    4   AppKit                              0x00007fff87e150a2 _NSCreateWindow + 187
    5   AppKit                              0x00007fff87c72e9d -[NSWindow _commonAwake] + 1434
    6   AppKit                              0x00007fff87bff80a -[NSWindow _commonInitFrame:styleMask:backing:defer:] + 864
    7   AppKit                              0x00007fff87bfedb0 -[NSWindow _initContent:styleMask:backing:defer:contentView:] + 1487
    8   AppKit                              0x00007fff87bfe7db -[NSWindow initWithContentRect:styleMask:backing:defer:] + 45
    9   createwindow                        0x0000000100001389 main + 249
    10  libdyld.dylib                       0x00007fff8b5dc5c9 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException 

我正在运行 XCode 6.3.2。在 OS X 10.10 优胜美地。

4

0 回答 0