gnustep-dev
[Top][All Lists]
Advanced

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

Re: Problems with NSTextStorage


From: Nicola Pero
Subject: Re: Problems with NSTextStorage
Date: Mon, 11 Feb 2002 22:25:03 +0000 (GMT)

> > > I am currently implementing an integrated editor in ProjectCenter. 
> > > Therefore
> > > I create the textsystem 'by hand' and connect the objects manually.
> > Why ?
> 
> 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.


> 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.

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 :-)

Let me know if you have problems etc


> > > Furthermore calling init instead of initWithString:attributes: 
> > > is not implemented/supported at all, although it should be, according to
> > > Apple's documentation, explaining the text system. What is correct here?
> > 
> > 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).

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.




reply via email to

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