我对可可很陌生,
我想替换NSTextView的内容。
我找到一个名为setString of NSText的函数,NSTextView继承了NSText。
那么为什么我会得到一个错误:
NSTextView' does not have a member named 'setString
谢谢。
现在,我必须使用NSTextView.insertText插入一些文本。
我需要无限期地清理NSTextView。我用下面的代码来做这件事: @property IBOutlet NSTextView *textView; self.textView设置字符串:@“”; but this code overflows memory if used unlimited amout of times. As a shortened example, this code:
```javascript 循环: self.textView设置字符串:@“”; 转到循环; 内存溢出速度非常快。如何在不溢出内存的情况下无限次清理NSTextView?
我和可可共事的第二天。我设置了一个NSTextView,它的属性字符串绑定到一个NSArrayController (我使用的是核心数据):
controller key: selection
model key path: myString
我读到过NSTextView需要一个NSAttributedString,这就是为什么在尝试设置属性值时抛出异常的原因。
NSInvalidArgumentException', reason: 'Unacceptable type of value for attribute: property = "myString"
我注意到,与OSX相比,NSTextView不能因为弱引用(如果你试图将它链接到弱,你就会得到)
Cannot form weak reference to instance (0x600000122da0) of class NSTextView. It is possible that this object was over-released, or is in the process of deallocation.
此外,默认情况下,XCode的出口被创建为赋值。
为什么不能有弱引用呢?原因是什么?
按照建议的,我使用以下代码取消选择一个NSTextView。不幸的是,什么都没有发生。我已经尽我所知对其进行了调试,但似乎一切都正常工作,但这并不影响NSTextView。
代码:
// Sets the scrolling bounds and behavior. This might be useful, but I don't know
[[textView textContainer] setContainerSize:NSMakeSize(FLT_MAX, FLT_MAX)];
[[textView textContainer] setWidthTracksTextView: