Re: trouble with NSRange.location
Re: trouble with NSRange.location
- Subject: Re: trouble with NSRange.location
- From: Fritz Anderson <email@hidden>
- Date: Thu, 18 Dec 2003 11:45:58 -0600
On 18 Dec 2003, at 11:00 AM, Robert Burns wrote:
I've searched the archives and much documentation and can't understand
what's going wrong with my use of an NSTextStorage editedRange.
Whenever I get the editedRange.location (and I've tried this many
different ways) I always get the integer 2147483647 instead of
something within the length of the text.
Looking at the documentation for -[NSTextStorage editedRange], I notice
that it is intended for use by delegates and layout methods of
NSTextStorage, during processes and notifications that occur and have
been cleaned up before the NSTextView textDidChange: notification you
call it in. The documentation says "Returns the range of the receiver
to which _pending_ changes have been made, whether of characters or of
attributes." It's therefore not surprising that the range is no longer
valid when the changes are no longer pending.
The constant 2147483647 (hex 0x7fffffff), when used in an NSRange
location, is named as NSNotFound; it indicates the NSRange is not valid
data. You shouldn't be relying on your observations of the length
field. Sorry for the bad news.
-- F
If I get the
editedRange.length it gives me exactly what I expect (i.e., 1 if no
text is selected, 0 if it's a backspace delete, and n when selected
text is changedf n characters in length). So does anyone know what I'm
missing here?
This class is serving as a delegate to an NSTextView, established in
IB.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.