`- (void)insertText:(NSString *)text {
if (text.length == 0) return;
if (!NSEqualRanges(_lastTypeRange, _selectedTextRange.asRange)) {
[self _saveToUndoStack];
[self _resetRedoStack];
}
[self replaceRange:_selectedTextRange withText:text];
}`
一输入文字就进入这里,另外完整的call stack:* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '* -[**NSPlaceholderArray initWithObjects:count:]: attempt to insert nil object from objects[0]'
* First throw call stack:
(
0 CoreFoundation 0x00000001132ffd85 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x00000001129eddeb objc_exception_throw + 48
2 CoreFoundation 0x00000001131b8a52 -[__NSPlaceholderArray initWithObjects:count:] + 290
3 CoreFoundation 0x00000001132150b4 +[NSArray arrayWithObjects:count:] + 52
4 nihao 0x000000010c826e31 __53-[WBStatusComposeTextParser parseText:selectedRange:]_block_invoke + 481
5 libdispatch.dylib 0x0000000113ae83eb _dispatch_client_callout + 8
6 libdispatch.dylib 0x0000000113ad3d68 dispatch_once_f + 543
7 nihao 0x000000010c824bb8 -[WBStatusComposeTextParser parseText:selectedRange:] + 216
8 nihao 0x000000010c399a0b -[YYTextView _parseText] + 267
9 nihao 0x000000010c3ab6b4 -[YYTextView replaceRange:withText:] + 1988
10 nihao 0x000000010c3a93bd -[YYTextView insertText:] + 317
11 UIKit 0x0000000110edb9f8 -[UIKeyboardImpl insertText:] + 149
12 UIKit 0x0000000110ed815b -[UIKeyboardImpl performKeyboardOutput:] + 496
13 UIKit 0x0000000110ed7d48 __55-[UIKeyboardImpl handleKeyboardInput:executionContext:]_block_invoke_2 + 164
14 UIKit 0x00000001116682f3 -[UIKeyboardTaskQueue continueExecutionOnMainThread] + 345
15 Foundation 0x000000010f8197a7 __NSThreadPerformPerform + 283
16 CoreFoundation 0x0000000113225301 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 17
17 CoreFoundation 0x000000011321b22c __CFRunLoopDoSources0 + 556
18 CoreFoundation 0x000000011321a6e3 __CFRunLoopRun + 867
19 CoreFoundation 0x000000011321a0f8 CFRunLoopRunSpecific + 488
20 GraphicsServices 0x0000000114a71ad2 GSEventRunModal + 161
21 UIKit 0x0000000110c2df09 UIApplicationMain + 171
22 nihao 0x000000010c844eaf main + 111
23 libdyld.dylib 0x0000000113b1c92d start + 1
24 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
最后是崩溃在这里(系统的dispatch文件:once.h):#ifdef BLOCKS
__OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_4_0)
DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
void
dispatch_once(dispatch_once_t *predicate, dispatch_block_t block);
DISPATCH_INLINE DISPATCH_ALWAYS_INLINE DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
void
_dispatch_once(dispatch_once_t _predicate, dispatch_block_t block)
{
if (DISPATCH_EXPECT(_predicate, ~0l) != ~0l) {
dispatch_once(predicate, block);
}
}