Re: Swapping the NSTextContainer on an NSTextView
Re: Swapping the NSTextContainer on an NSTextView
- Subject: Re: Swapping the NSTextContainer on an NSTextView
- From: Rob Minerick <email@hidden>
- Date: Wed, 04 Feb 2004 10:05:13 -0600
> Keep in mind that having a single layout manager and swapping text on
> it means that layout has to be re-done each time you change the
> contents. If you keep a separate layout manager around for each
> document then you will have the layout information cached with it, so
> you won't have to do any layout when you change views. The layout
> manager is by far the heaviest-weight object here; having a single
> text view won't save you much compared with the cost of having
> separate layout managers. If you have many documents to manage, you
> could do something intermediate--say, have a pool of N layout
managers
> for the N most recently displayed documents, and swap the text for
one
> of them only when you need to display something outside of that pool.
My thought was to just test the different options (the different
points
at which I can duplicate or reuse objects) and see. I suspect that I
would end up just switching the textStorage and recycling the rest
because although there are quite a lot of files, they are all
reasonably short (assembly source files - the code I am writing if for
an assembler IDE). However, if multiple layoutManagers shared many of
their 'helper' classes, as the docs say they do, there may be some
benefit in duplicating at least some of them (as you suggest, with a
pool).
The problem is that, no matter where I switch, I still have the
exceptions thrown.
The workaround that I use in a similar situation is to reset the
selected range to 0,0 in the NSTextView. Something like this:
[[self theTextView] setSelectedRange:NSMakeRange(0,0)];
This gets around the problem of exceptions being thrown, but doesn't
help with what seemed to be one of your original problems: saving the
previous entry point/selection.
--
Rob
_______________________________________________
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.