Re: NSTextStorage subclassing issue in 10.4
Re: NSTextStorage subclassing issue in 10.4
- Subject: Re: NSTextStorage subclassing issue in 10.4
- From: Keith Blount <email@hidden>
- Date: Wed, 25 May 2005 11:07:02 -0700 (PDT)
- Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys
Many thanks for your reply, much appreciated.
> The best would be to call "fixNoteAttributes" from
> within NSTextStorage's "processEditing", rather than
> in each of the primitive mutators. I would assume
> that the new list stuff in Cocoa is smart enough to
> wrap all the list bullet modifications with calls to
> "beginEditing" and "endEditing", so that way you
> will only have to fix your note attributes once.
You would think so, but in fact the new list stuff
isn't this smart - an NSLog shows that -beginEditing
and -endEditing get sent for *every* bullet point
inserted, they don't just bracket the whole block.
This means that if you have text with, say 200
paragraphs in it and try to list format the whole lot,
then begin- and endEditing get sent 200 times, and
thus my code gets called 200 times. I can't see any
simple way around this - obviously, my code only needs
to get called the once, after the lot is fixed.
> You
> can also restrict the range to fix to the
> "editedRange" rather than the whole storage, though
> of course that doesn't help you in this particular
> case, but I imagine it would for typing and other
> small/rapid changes.
In my particular case this won't work, seeing as all
the notes after the edited range need updating too, as
their ranges will also have been affected.
> when
> "replaceCharactersInRange:withString:" is invoked,
> you don't need to scan any note objects preceeding
> the replaced range. Similarly, when attributes are
> applied, only note objects in the affected range
> could possibly have been added or removed.
>
This is a good point, and definitely something I could
optimise, but at the moment speed is fine (as in no
noticable speed hit at all) for typing and everything
else except for list formatting large chunks of text,
and this won't help with the the test case of
selecting the whole of a large document and changing
the list formatting to bullets, for instance.
So at the moment, I'm still stuck on how to fix
this... I have tried using the perform after delay and
cancel selector NSObject methods in an attempt to get
the method called only once, but this didn't work
either.
Any other suggestions would be really appreciated.
Many thanks,
Keith
__________________________________
Do you Yahoo!?
Yahoo! Small Business - Try our new Resources site
http://smallbusiness.yahoo.com/resources/
_______________________________________________
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