如果是readonly,为什么我可以通过textstograge属性编辑UITextView内容?

时间:2016-07-27 10:30:17

标签: uitextview readonly

从Apple文档中读取UITextView,我读了这篇文章的textStorage属性

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的属性吗?

1 个答案:

答案 0 :(得分:0)

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

然而,它没有说明它所指向的对象是否可变。因此,您可以编辑当前的textStorage,但不能将其替换为其他NSTextStorage对象。