2016-07-27 60 views
0

苹果文档阅读的UITextView,我读到这对textStorage财产为什么我可以通过textstograge属性编辑UITextView内容(如果是只读的)?

The text storage object holding the text displayed in this text view. (read-only) 

Declaration 

OBJECTIVE-C 
@property(nonatomic, readonly, strong) NSTextStorage *textStorage 

但在我教授的笔记

[self.body.textStorage 
setAttributes:@{NSForegroundColorAttributeName : sender.backgroundColor} 
range:self.body.selectedRange]; 

它是如何textStorage可能的编辑属性,如果是只读的?

回答

0

该属性是指向NSTextStorage对象的指针。 readonly属性将该属性标记为只读,在这种情况下,它表示指针不能更改。

但是,它并没有说它指向的对象是否是可变的。因此,您可以编辑当前的textStorage,但不能用不同的NSTextStorage对象替换它。

+0

因此,指针(内存地址)的值不能改变。在你看来,为什么指针是只读是很重要的? – ndPPPhz

+0

这意味着UITextView内部可以假定textStorage是给定的子类。 – Mats

+0

呃...很抱歉,但我不明白...:/ – ndPPPhz

相关问题