• 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
NSTextStorage subclassing issue in 10.4
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSTextStorage subclassing issue in 10.4


  • Subject: NSTextStorage subclassing issue in 10.4
  • From: Keith Blount <email@hidden>
  • Date: Tue, 24 May 2005 09:52:58 -0700 (PDT)
  • Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys

Hello,

I am having some slowdown issues in a very specific
circumstance under Tiger and would be very grateful if
anybody could offer me any advice on how to fix this.

I have a text view that uses a subclass of
NSTextStorage. This subclass has an extra attribute
entitled KBNoteAttributeName, which associates a
KBNote object with a range of text. A KBNote object is
just a very simple model object (NSObject subclass)
that stores a string and the range of text with which
it is associated. In my concrete subclass of
NSTextStorage, I call my own -fixNoteAttributes method
to update the associated ranges of the notes from
-replaceCharactersInRange:withString:,
-setAttributes:range:, and -addAttribute:value:range:,
as specified by the docs and elsewhere. All this works
fine and quickly EXCEPT when there is a large amount
of text and the user selects it all and applies
Tiger's list formatting (eg. bullets) to the whole
selection. It seems that one problem is that
-fixNoteAttributes gets called *every* time a bullet
point is added rather than after all of the bullet
points have been added.

This is my fixNoteAttributes method:

-(void)fixNoteAttributes
{
	NSRange effectiveRange;
	KBNote *note;

	// notes is an NSMutableArray which stores all notes
as a convenience
	[notes removeAllObjects];

	NSRange all = NSMakeRange(0,[self length];

	while (all.length > 0)
	{
		note = [self attribute:KBNoteAttributeName
			atIndex:all.location
			longestEffectiveRange:&effectiveRange
			inRange:all

		if (note)
		{
			[note setAttachedCharRange:effectiveRange]; //
update
			[notes addObject:note];
		}

		all = NSMakeRange(NSMaxRange(effectiveRange),
				NSMaxRange(all) - NSMaxRange(effectiveRange));
	}
}

If anybody has any ideas on how I might improve this
or get rid of the slowdown issues I am experiencing, i
would be very grateful.

Many thanks in advance,
Keith

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
 _______________________________________________
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

  • Prev by Date: Re: Object References in Obj-C
  • Next by Date: Re: FYI: User feedback for LSMinimumSystemVersion
  • Previous by thread: Re: AppleScript: Returning object references in Cocoa
  • Next by thread: Re: NSTextStorage subclassing issue in 10.4
  • Index(es):
    • Date
    • Thread