質問

I have an NSTextStorage delegate imlementing textStorageDidProcessEditing:. Unfortunately, the userInfo doesn't contain any details about the changes to the text.

How can I find out what actually changed?

Ideally I'd like to know everything sent to [NSLayoutManager textStorage:edited:range:changeInLength:invalidatedRange:], but just the edited range would be good enough.

役に立ちましたか?

解決

You could just write your own subclass of NSLayoutManager and add it to your NSTextSTorage using addLayoutManager:.

他のヒント

You could also use KVO to observe the characters property of your NSTextStorage object (or any other property of it) and you get exactly what is changed in

- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context 

Use NSTextStorage's getter methods editedRange and changeInLength.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top