Re: Swapping the NSTextContainer on an NSTextView
Re: Swapping the NSTextContainer on an NSTextView
- Subject: Re: Swapping the NSTextContainer on an NSTextView
- From: Douglas Davidson <email@hidden>
- Date: Tue, 3 Feb 2004 12:41:55 -0800
On Feb 3, 2004, at 12:19 PM, Robert Goldsmith wrote:
Actually, I started off with one NSLayoutManager, NSTextContainer and
NSTextView and just wanted to swap in and out the NSTextStorage
objects because that would minimise the number of objects hanging
around but as that failed (for actually very similar reasons and with
similar exceptions) I moved up the chain to where I am atm. I would
prefer not to have to have NSTextViews hanging around that get swapped
in and out. After all, what is the point of putting so much effort
into separating the text system up into such a structure if you need
to create the entire structure once per potentially visible text
segment anyhow?! :) And the text system objects are so big and
cumbersome the less I need to duplicate the better, to be fair :)
You should be able to swap the text storage in and out. What system
version are you running, and what is the exact code you were using to
do this? There was a bug at one point that could cause problems if
things were done in a particular order. An alternative solution would
be to keep the text storage the same and simply swap its entire
contents around, using -[NSMutableAttributedString
setAttributedString:].
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.
Douglas Davidson
_______________________________________________
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.