Re: Out of bounds exception from NSTextView
Re: Out of bounds exception from NSTextView
- Subject: Re: Out of bounds exception from NSTextView
- From: Douglas Davidson <email@hidden>
- Date: Thu, 1 Sep 2005 16:01:38 -0700
On Sep 1, 2005, at 3:43 PM, Satoshi Matsumoto wrote:
But please try to use the method replaceCharactersInRange: for the
textStorage as below.
NSRange range = [myTextView selectedRange];
[myTextView shouldChangeTextInRange:range
replacementString:string];
[[myTextView textStorage] replaceCharactersInRange:range
withString:string];
[myTextView didChangeText];
It's best in general if you listen to the return value of the should-
change method, e.g.
if ([myTextView shouldChangeTextInRange:range
replacementString:string]) {
[[myTextView textStorage] replaceCharactersInRange:range
withString:string];
[myTextView didChangeText];
}
If you're going to be making more than one change to the text storage
in a row, you should wrap the sequence of changes with beginEditing/
endEditing for efficiency.
Douglas Davidson
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden