NSTextView,appendString和NSConcreteTextStorage的错误

时间:2012-02-24 17:44:10

标签: cocoa nstextview

这是我第一次使用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
...

任何评论都非常赞赏。

1 个答案:

答案 0 :(得分:2)

-appendString:是NSMutableString上的一个方法。 NSTextStorage是NSMutable Attributed String的子类。您可以在textStorage的-appendString:上调用mutableString,如下所示:

[commandHistoryTextView.textStorage.mutableString appendString:outputString];