我有一个NSTextField,它绑定到我在我的nib中包含的对象中的int。当对象更改其int时,文本字段会跟随,一切看起来都很好。
但是,当我尝试手动更改它时,程序会在我按下一个键后立即崩溃。它甚至没有进入我的setter方法,它只是与
崩溃Program received signal: “EXC_BAD_ACCESS”.
它甚至不在我的任何代码中...大概是,我的绑定错了,但我能做些什么会让它像那样陷入错误?
ETA:崩溃的堆栈帧:
Process: DocKeep [77998]
Path: /Users/acordex/Documents/projects/DocKeep/build/Debug/DocKeep.app/Contents/MacOS/DocKeep
Identifier: com.acordex.DocKeep
Version: 9.00 pre-Alpha (9.00 pre-Alpha)
Code Type: X86 (Native)
Parent Process: Instruments [77954]
Date/Time: 2010-07-29 10:01:11.927 -0400
OS Version: Mac OS X 10.6.4 (10F569)
Report Version: 6
Exception Type: EXC_BAD_ACCESS (SIGBUS)
Exception Codes: KERN_PROTECTION_FAILURE at 0x000000000000001c
Crashed Thread: 0 Dispatch queue: com.apple.main-thread
Thread 0 Crashed: Dispatch queue: com.apple.main-thread
0 com.apple.AppKit 0x954a4734 -[NSDocument(NSEditorRegistration) _isBeingEdited] + 24
1 com.apple.AppKit 0x954a4707 -[NSDocument isDocumentEdited] + 47
2 com.apple.AppKit 0x955b3900 -[NSDocument(NSEditorRegistration) objectDidBeginEditing:] + 48
3 com.apple.AppKit 0x95461ef9 -[NSValueBinder _startChanging] + 126
4 com.apple.AppKit 0x95461dc1 -[NSTextValueBinder _startChanging] + 60
5 com.apple.AppKit 0x95461d5f -[_NSBindingAdaptor _editor:didChangeEditingState:bindingAdaptor:] + 181
6 com.apple.AppKit 0x95461c9f -[_NSBindingAdaptor editorDidBeginEditing:] + 278
7 com.apple.AppKit 0x95442e5a -[NSTextField textShouldBeginEditing:] + 239
8 com.apple.AppKit 0x95441d0b -[NSTextView(NSSharing) shouldChangeTextInRanges:replacementStrings:] + 573
9 com.apple.AppKit 0x95464563 _NSDoUserReplaceForCharRange + 191
10 com.apple.AppKit 0x9546449e _NSDoUserDeleteForCharRange + 79
11 com.apple.AppKit 0x95463b07 -[NSTextView(NSKeyBindingCommands) deleteBackward:] + 684
12 com.apple.AppKit 0x9544b364 -[NSResponder doCommandBySelector:] + 77
13 com.apple.AppKit 0x9544ac7f -[NSTextView doCommandBySelector:] + 240
14 com.apple.AppKit 0x95439bbf -[NSKeyBindingManager(NSKeyBindingManager_MultiClients) interpretEventAsCommand:forClient:] + 1911
15 com.apple.AppKit 0x9543d44f -[NSTextInputContext handleEvent:] + 1604
16 com.apple.AppKit 0x95439229 -[NSView interpretKeyEvents:] + 209
17 com.apple.AppKit 0x9543ccd5 -[NSTextView keyDown:] + 751
18 com.apple.AppKit 0x9536df6c -[NSWindow sendEvent:] + 5757
19 com.apple.AppKit 0x95286aff -[NSApplication sendEvent:] + 6431
20 com.apple.AppKit 0x9521a5bb -[NSApplication run] + 917
21 com.apple.AppKit 0x952125ed NSApplicationMain + 574
22 com.acordex.DocKeep 0x0000224c main + 30 (main.m:14)
23 com.acordex.DocKeep 0x00002202 start + 54
Thread 1:
0 libSystem.B.dylib 0x94a319d2 __workq_kernreturn + 10
1 libSystem.B.dylib 0x94a31f68 _pthread_wqthread + 941
2 libSystem.B.dylib 0x94a31b86 start_wqthread + 30
Thread 2: Dispatch queue: com.apple.libdispatch-manager
0 libSystem.B.dylib 0x94a32942 kevent + 10
1 libSystem.B.dylib 0x94a3305c _dispatch_mgr_invoke + 215
2 libSystem.B.dylib 0x94a32519 _dispatch_queue_invoke + 163
3 libSystem.B.dylib 0x94a322be _dispatch_worker_thread2 + 240
4 libSystem.B.dylib 0x94a31d41 _pthread_wqthread + 390
5 libSystem.B.dylib 0x94a31b86 start_wqthread + 30
Thread 3:
0 libSystem.B.dylib 0x94a3a066 __semwait_signal + 10
1 libSystem.B.dylib 0x94a39d22 _pthread_cond_wait + 1191
2 libSystem.B.dylib 0x94a3b9b8 pthread_cond_wait$UNIX2003 + 73
3 com.apple.CoreVideo 0x96730c3e CVDisplayLink::runIOThread() + 1016
4 com.apple.CoreVideo 0x9673082a startIOThread(void*) + 156
5 libSystem.B.dylib 0x94a3981d _pthread_start + 345
6 libSystem.B.dylib 0x94a396a2 thread_start + 34
Thread 0 crashed with X86 Thread State (32-bit):
eax: 0x00000000 ebx: 0x954a472d ecx: 0x00000001 edx: 0x00000000
edi: 0x0045f650 esi: 0x0045f650 ebp: 0xbfffe738 esp: 0xbfffe720
ss: 0x0000001f efl: 0x00010282 eip: 0x954a4734 cs: 0x00000017
ds: 0x0000001f es: 0x0000001f fs: 0x00000000 gs: 0x00000037
cr2: 0x0000001c
我 DO 有一个文档类,它是NSDocument
的子类,文本域绑定到该文档对象的一个字段,但我不确定为什么这会重要
答案 0 :(得分:0)
环境变量NSBindingDebugLogLevel可能很有用。设置它并仔细检查您的日志以获取警告。如果在NSException raise上设置了断点,则可能看不到警告。
绑定应该使用int,绝对不能使用unsigned int。但是NSTextfield需要NSString,或者至少需要NSNumber和相关的NSNumberFormatter。