• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: empty string, or: totally clearing the NSTextStorage
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

References: 
 >Re: empty string, or: totally clearing the NSTextStorage (From: Ondra Cada <email@hidden>)

  • Prev by Date: Re: A CFStringRef that throws EXC_BAD_ACCESS
  • Next by Date: NSImageView & scroll
  • Previous by thread: Re: empty string, or: totally clearing the NSTextStorage
  • Next by thread: Re: Declarations near usage
  • Index(es):
    • Date
    • Thread