Re: empty string, or: totally clearing the NSTextStorage
Re: empty string, or: totally clearing the NSTextStorage
- Subject: Re: empty string, or: totally clearing the NSTextStorage
- From: Arthur Clemens <email@hidden>
- Date: Thu, 17 Oct 2002 15:57:07 +0200
>
Using "length-1" you keep there the last character, whatever it is. It
>
happens to be a newline.
For some reason my sent mails appear 3 hours later in the list... So I
was already to bed when I received replies.
This is right, I should not be using [textStorage length] - 1. The
culprit was somewhere else, and it took me some time to find it.
I was getting errors when I was removing all characters using "length",
but it was not that I was accessing an invalid range.
After clearing of the text storage I was trying to get the attributes
of NSLinkAttributeName at index 0:
NSString *keyword = [[_view textStorage] attribute:NSLinkAttributeName
atIndex:loc effectiveRange:nil];
(where loc = 0)
Appearantly this is not valid, so I added a check to return if loc == 0.
In the end, to clear the text storage, [self setString:@""] seems to be
the most elegant solution.
Thanks for all help.
Arthur
_______________________________________________
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.