Domanda

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.

È stato utile?

Soluzione

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

Altri suggerimenti

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top