[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problems with NSTextStorage

From: Philippe C.D. Robert
Subject: Re: Problems with NSTextStorage
Date: Tue, 12 Feb 2002 20:17:25 +0100

On Mon, 11 Feb 2002 22:25:03 +0000 (GMT)
Nicola Pero <n.pero@mi.flashnet.it> wrote:
> > Doing some multi representation stuff of the same text requires that AFAIK. 
> Ok - fine - I was asking also because I need to warn you :-) - don't
> expect the gnustep text system to do all the advanced things with multiple
> text objects interaction like the apple system does ... it's simply not
> implemented yet.  I'm slowly trying to push the text system forward now
> ... but it requires patience and a lot of time.

No problem, it seems that the stuff I need right now are so simple, that it
> > Or is there a way to set the textstorage for an existing textview? 
> Ah - Ok - that might work - having the same text storage displayed in
> multiple (completely independent) textviews might work ?  Yes - it might
> actually work.

It does.

> To answer your question, I think you can build up the whole text network
> by creating the textview, then replace the textStorage with the one you
> want by doing
> [[textView layoutManager] replaceTextStorage: yourNewTextStorage];
> It might work :-)

Yup I guess so - never tried it, though...:-)
> Let me know if you have problems etc

Yup, thanks. 

> > > As far as I know, [NSTextStorage -init] is implemented, and it works -
> > > it's inherited from NSMutableAttributedString.  Let me know if I'm missing
> > > something.
> > 
> > I guess you are right, but where is _layoutManagers initialised when calling
> > -init and not -initWithString:attributes: ?
> -initWithString:attributes: is the designated initializer, which means
> that in the superclass -init is defined in terms of
> -initWithString:attributes: - probably something like
> - (id)init 
> {
>   return [self initWithString:nil  attributes:nil];
> }
> NSTextStorage is a subclass which overrides the designated initializer
> (-initWithString:attributes:).  In the superclass all other initializers
> are defined in terms of this one, so they automatically work for
> subclasses once you override the designated initializer. (in other words,
> to answer your question, -init in the superclass calls
> -initWithString:attributes: in the subclass, which initializes
> _layoutManagers, then calls -initWithString:attributes: in the superclass,
> which does the rest of the init).

Yes of course - I simply missed the presence of -init in NSAttributedString,
sorry for asking before thinking twice...

> Somewhere - I think in the ObjC doc from apple, there is an explanation of
> designated initializers - really worth reading - particularly because Java
> is completely different with regards to initializers (in Java constructors
> are not inherited at all) so if you're used to Java, this issue might
> confuse you at first sight.

I know, Nicola, I know - I am coding with NEXTSTEP/OPENSTEP/GNUstep for 10 
years now ... 


But you should put such nice explanations in a programmer's guide for GNUstep
beginners, this would be very valuable, indeed!

Philippe C.D. Robert
Software Engineer
Silicon Graphics, Inc.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]