gpt4 book ai didi

objective-c - 无法从类 NSWindow 的对象创建 BOOL

转载 作者:行者123 更新时间:2023-12-03 17:41:44 26 4
gpt4 key购买 nike

当我从 NIB 加载窗口时,我看到此错误。该错误出现在 Apple 代码的深处。我的加载代码全部正确执行,并且在运行时所有 socket 都设置正确。

Cannot create BOOL from object <NSWindow: 0x7f883b44f770> of class NSWindow

这是正在调用的代码

- (void)awakeFromNib{    
[self showLoginSheet];
}

- (void)showLoginSheet
// User has asked to see the custom display. Display it.
{
if (!self.loginSheet)
[NSBundle loadNibNamed:@"LoginSheet" owner:self];
//Check the myCustomSheet instance variable to make sure the custom sheet does not already exist

[NSApp beginSheet: self.loginSheet
modalForWindow: [[NSApp delegate] window]
modalDelegate: self
didEndSelector: NULL
contextInfo: NULL];
}

堆栈跟踪是

2012-07-21 21:09:57.575 MingleLookBooks[15934:503] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Cannot create BOOL from object <NSWindow: 0x7f883b44f770> of class NSWindow'
*** First throw call stack:
(
0 CoreFoundation 0x00007fff91305f56 __exceptionPreprocess + 198
1 libobjc.A.dylib 0x00007fff874b9d5e objc_exception_throw + 43
2 CoreFoundation 0x00007fff91305d8a +[NSException raise:format:arguments:] + 106
3 AppKit 0x00007fff9038a394 _NSBoolFromValue + 421
4 AppKit 0x00007fff903b1c5a -[NSEditableBinder hiddenState] + 83
5 AppKit 0x00007fff903b1bdf -[NSEditableBinder _hiddenStateWithMode:] + 41
6 AppKit 0x00007fff90389eaa -[NSEditableBinder _setStatesImmediatelyInObject:mode:triggerRedisplay:] + 579
7 AppKit 0x00007fff90389c60 -[NSEditableBinder _observeValueForKeyPath:ofObject:context:] + 123
8 AppKit 0x00007fff901a1643 -[NSObject(NSKeyValueBindingCreation) bind:toObject:withKeyPath:options:] + 591
9 AppKit 0x00007fff9019a959 -[NSIBObjectData nibInstantiateWithOwner:topLevelObjects:] + 1079
10 AppKit 0x00007fff90190f73 loadNib + 322
11 AppKit 0x00007fff90190470 +[NSBundle(NSNibLoading) _loadNibFile:nameTable:withZone:ownerBundle:] + 217
12 AppKit 0x00007fff9019038b +[NSBundle(NSNibLoading) loadNibFile:externalNameTable:withZone:] + 141
13 AppKit 0x00007fff901902ce +[NSBundle(NSNibLoading) loadNibNamed:owner:] + 364
14 MingleLookBooks 0x000000010ef0917a -[AppController showLoginSheet] + 138
15 MingleLookBooks 0x000000010ef08ffb -[AppController awakeFromNib] + 43
16 CoreFoundation 0x00007fff912fcfb1 -[NSObject performSelector:] + 49
17 CoreFoundation 0x00007fff912fcf32 -[NSSet makeObjectsPerformSelector:] + 274
18 AppKit 0x00007fff9019a9ff -[NSIBObjectData nibInstantiateWithOwner:topLevelObjects:] + 1245
19 AppKit 0x00007fff90190f73 loadNib + 322
20 AppKit 0x00007fff90190470 +[NSBundle(NSNibLoading) _loadNibFile:nameTable:withZone:ownerBundle:] + 217
21 AppKit 0x00007fff9019038b +[NSBundle(NSNibLoading) loadNibFile:externalNameTable:withZone:] + 141
22 AppKit 0x00007fff901902ce +[NSBundle(NSNibLoading) loadNibNamed:owner:] + 364
23 AppKit 0x00007fff9040106f NSApplicationMain + 398
24 MingleLookBooks 0x000000010ef08f32 main + 34
25 MingleLookBooks 0x000000010ef08f04 start + 52
)
terminate called throwing an exception(lldb)

正如您从堆栈跟踪中看到的,这似乎与我的代码无关。我究竟做错了什么?我不知道,类似问题的其他答案也没有真正的帮助。

最佳答案

看起来您的 XIB 中的绑定(bind)设置不正确。

关于objective-c - 无法从类 NSWindow 的对象创建 BOOL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11597082/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com