这是我第一次使用NSTextView
,我很难弄清楚它是如何工作的,我有一行这样的代码:
[[commandHistoryTextView textStorage] appendString:outputString];
我得到这个错误:
2012-02-24 12:40:52.971 binoclean[37863:703] Exception detected while handling key input.
2012-02-24 12:40:52.971 binoclean[37863:703] -[NSConcreteTextStorage appendString:]: unrecognized selector sent to instance 0x2cca10
2012-02-24 12:40:52.975 binoclean[37863:703] (
0 CoreFoundation 0x9bf55b67 __raiseError + 231
1 libobjc.A.dylib 0x9b5c8149 objc_exception_throw + 155
2 CoreFoundation 0x9bf59170 -[NSObject doesNotRecognizeSelector:] + 256
3 CoreFoundation 0x9bea7da9 ___forwarding___ + 457
...
非常感谢任何评论。
-appendString:
是NSMutableString上的一个方法。NSTextStorage是NSMutableAttributedString的一个子类。您可以在文本存储的mutableString
上调用-appendString:
,如下所示:
[commandHistoryTextView.textStorage.mutableString appendString:outputString];