当我显示 NSWindow 一次时,它会显示,但是当我再次打开 NSWindow 时,它会崩溃
崩溃时出现此错误
线程1:EXC_BAD_ACCESS(代码=1,地址=0x2d006e0080)
在这行代码中
if mainWindow != nil {
mainWindow.setFrame(NSRect(x: xxxx,
y: yyyy,
width: width,
height: height),
display: true,
animate: true)
// This line of code is where the crash happens,
// if I comment this, it still crashes
} else {
mainWindow = NSWindow(contentRect: NSRect(x: 50,
y: 50,
width: 100,
height: 600),
styleMask: [
.titled,
.resizable,
.miniaturizable,
.closable
],
backing: .buffered,
defer: true)
}
mainWindow.titlebarAppearsTransparent = true
// When I comment the 2 line, this one crashes
mainWindow.contentView = myView
mainWindow.delegate = self