このコードの何が問題なのかを突き止めようとしています。ユーザーがテーブル ビューの 1 つをクリックしたときに更新したい文字列 NSTextView があります。今のところ、文字列「Notes」を表示するようにしようとしています。
私が間違っていることについて何か考えはありますか? 私は beginEditing: と endEditing: を調べましたが、成功しませんでした。
//
// MyAppDelegate.h
@property IBOutlet NSTextView* stickyNoteContainer;
//
// MyAppDelegate.m
-(void)updateOverview{
[stickyNoteContainer setString:@"Notes"];
}
スタックは次のとおりです。
MyApp[1176:303] *** -[NSBigMutableString _getBlockStart:end:contentsEnd:forRange:stopAtLineSeparators:]: Range or index out of bounds
2013-09-23 15:04:12.084 MyApp[1176:303] (
0 CoreFoundation 0x00007fff917eaf56 __exceptionPreprocess + 198
1 libobjc.A.dylib 0x00007fff95bb7d5e objc_exception_throw + 43
2 CoreFoundation 0x00007fff917ead8a +[NSException raise:format:arguments:] + 106
3 CoreFoundation 0x00007fff917ead14 +[NSException raise:format:] + 116
4 Foundation 0x00007fff955afbc5 -[NSString _getBlockStart:end:contentsEnd:forRange:stopAtLineSeparators:] + 160
5 Foundation 0x00007fff955afb1e -[NSString getParagraphStart:end:contentsEnd:forRange:] + 40
6 AppKit 0x00007fff8e5c1cd7 _NSFastFillAllLayoutHolesForGlyphRange + 1040
7 AppKit 0x00007fff8eb31bb4 -[NSTextView(NSPrivate) _ensureLayoutCompleteForVisibleRectWithExtensionFactor:minimumExtensionDistance:repetitions:] + 563
8 AppKit 0x00007fff8eb2d13c -[NSTextView(NSPrivate) _ensureLayoutCompleteForVisibleRectWithExtension:] + 45
9 AppKit 0x00007fff8e6b9650 -[NSTextView setNeedsDisplayInRect:avoidAdditionalLayout:] + 2078
10 AppKit 0x00007fff8e6bf1c1 -[NSLayoutManager(NSPrivate) _resizeTextViewForTextContainer:] + 5690
11 AppKit 0x00007fff8e5b0110 -[NSLayoutManager(NSPrivate) _recalculateUsageForTextContainerAtIndex:] + 2678
12 AppKit 0x00007fff8e96b948 _enableTextViewResizing + 209
13 AppKit 0x00007fff8e5a8454 -[NSLayoutManager textStorage:edited:range:changeInLength:invalidatedRange:] + 582
14 AppKit 0x00007fff8e5a81f6 -[NSTextStorage _notifyEdited:range:changeInLength:invalidatedRange:] + 155
15 AppKit 0x00007fff8e681133 -[NSTextStorage processEditing] + 205
16 AppKit 0x00007fff8e681cab -[NSTextStorage endEditing] + 81
17 MyApp 0x0000000100007938 -[MyAppDelegate updateOverview] + 1624
18 MyApp 0x0000000100008751 -[MyAppDelegate tableViewSelectionDidChange:] + 177
19 Foundation 0x00007fff95550d0e __-[NSNotificationCenter addObserver:selector:name:object:]_block_invoke_1 + 47
20 CoreFoundation 0x00007fff917937ba _CFXNotificationPost + 2634
21 Foundation 0x00007fff9553cfc3 -[NSNotificationCenter postNotificationName:object:userInfo:] + 65
22 AppKit 0x00007fff8e674049 -[NSTableView _sendSelectionChangedNotificationForRows:columns:] + 203
23 AppKit 0x00007fff8e64ab0a -[NSTableView _enableSelectionPostingAndPost] + 425
24 AppKit 0x00007fff8e670e58 -[NSTableView mouseDown:] + 5030
25 AppKit 0x00007fff8e5d6c98 -[NSWindow sendEvent:] + 6306
26 AppKit 0x00007fff8e5703a5 -[NSApplication sendEvent:] + 5593
27 AppKit 0x00007fff8e506a0e -[NSApplication run] + 555
28 AppKit 0x00007fff8e782eac NSApplicationMain + 867
29 MyApp 0x0000000100002002 main + 34
30 MyApp 0x0000000100001fd4 start + 52
)
EDIT : - (void)applicationDidFinishLaunching: ルーチンの実行中、プログラムの初期化の最後にコードが実際に例外なく 2 回実行されることに気付きました。その後、トリガーは失敗します。これは何を示唆していますか?
EDIT 2 : insertText: appends を使用するという事実は脇に置いてください。
MyApp[1919:303] *** -[NSBigMutableString _getBlockStart:end:contentsEnd:forRange:stopAtLineSeparators:]: Range or index out of bounds
2013-09-23 15:34:03.956 MyApp[1919:303] (
0 CoreFoundation 0x00007fff917eaf56 __exceptionPreprocess + 198
1 libobjc.A.dylib 0x00007fff95bb7d5e objc_exception_throw + 43
2 CoreFoundation 0x00007fff917ead8a +[NSException raise:format:arguments:] + 106
3 CoreFoundation 0x00007fff917ead14 +[NSException raise:format:] + 116
4 Foundation 0x00007fff955afbc5 -[NSString _getBlockStart:end:contentsEnd:forRange:stopAtLineSeparators:] + 160
5 Foundation 0x00007fff955afb1e -[NSString getParagraphStart:end:contentsEnd:forRange:] + 40
6 AppKit 0x00007fff8e5c1cd7 _NSFastFillAllLayoutHolesForGlyphRange + 1040
7 AppKit 0x00007fff8eb31bb4 -[NSTextView(NSPrivate) _ensureLayoutCompleteForVisibleRectWithExtensionFactor:minimumExtensionDistance:repetitions:] + 563
8 AppKit 0x00007fff8eb2d13c -[NSTextView(NSPrivate) _ensureLayoutCompleteForVisibleRectWithExtension:] + 45
9 AppKit 0x00007fff8e6b9650 -[NSTextView setNeedsDisplayInRect:avoidAdditionalLayout:] + 2078
10 AppKit 0x00007fff8e6bf1c1 -[NSLayoutManager(NSPrivate) _resizeTextViewForTextContainer:] + 5690
11 AppKit 0x00007fff8e5b0110 -[NSLayoutManager(NSPrivate) _recalculateUsageForTextContainerAtIndex:] + 2678
12 AppKit 0x00007fff8e96b948 _enableTextViewResizing + 209
13 AppKit 0x00007fff8e5a8454 -[NSLayoutManager textStorage:edited:range:changeInLength:invalidatedRange:] + 582
14 AppKit 0x00007fff8e5a81f6 -[NSTextStorage _notifyEdited:range:changeInLength:invalidatedRange:] + 155
15 AppKit 0x00007fff8e681133 -[NSTextStorage processEditing] + 205
16 AppKit 0x00007fff8e681cab -[NSTextStorage endEditing] + 81
17 AppKit 0x00007fff8eb0620f -[NSTextView insertText:replacementRange:] + 2013
18 AppKit 0x00007fff8eb05a25 -[NSTextView insertText:] + 320
19 MyApp 0x00000001000078c1 -[MyAppDelegate updateOverview] + 1569
20 MyApp 0x0000000100008751 -[MyAppDelegate tableViewSelectionDidChange:] + 177
21 Foundation 0x00007fff95550d0e __-[NSNotificationCenter addObserver:selector:name:object:]_block_invoke_1 + 47
22 CoreFoundation 0x00007fff917937ba _CFXNotificationPost + 2634
23 Foundation 0x00007fff9553cfc3 -[NSNotificationCenter postNotificationName:object:userInfo:] + 65
24 AppKit 0x00007fff8e674049 -[NSTableView _sendSelectionChangedNotificationForRows:columns:] + 203
25 AppKit 0x00007fff8e64ab0a -[NSTableView _enableSelectionPostingAndPost] + 425
26 AppKit 0x00007fff8e670e58 -[NSTableView mouseDown:] + 5030
27 AppKit 0x00007fff8e5d6c98 -[NSWindow sendEvent:] + 6306
28 AppKit 0x00007fff8e5703a5 -[NSApplication sendEvent:] + 5593
29 AppKit 0x00007fff8e506a0e -[NSApplication run] + 555
30 AppKit 0x00007fff8e782eac NSApplicationMain + 867
31 MyApp 0x0000000100001fc2 main + 34
32 MyApp 0x0000000100001f94 start + 52
)