سؤال

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