[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re[2]: NSString changes breaks...
From: |
Manuel Guesdon |
Subject: |
Re[2]: NSString changes breaks... |
Date: |
Tue, 31 Oct 2000 19:58:51 +0100 (CET) |
On Tue, 31 Oct 2000 17:35:08 +0000 Richard wrote:
>| The -initWithCharactersNoCopy:length:freeWhenDone: is currently a primitive
>for NSString and
>| -initWithCapacity: is primitive for NSMutableString, but I'm not sure if
>NSMutableString should
>| implement -initWithCharactersNoCopy:length:freeWhenDone: using
>-initWithCapacity: and -replaceCharactersInRange:withString:. At present, it
>doesn't.
>|
>| > GSWElementIDString doesn't have any ivar. It's just an empty class with a
>category.
>|
>| If it has no ivars, how dis it expected to work?
I think I haven't understand completely how NSStrings work. I was thinking my
GSWElementIDString class use NSMutableString ivars and methods. I've checked
the previous core/base code and found no ivar in NSMutableString too.
What I understand now, please correct me if I'm wrong:
If I do a id s1=[NSMutableString new], I get a GSMString*
If I do a id s2=[GSWElementIDString new], I get a GSWElementIDString*
(if GSWElementIDString has no specific init method).
If I do a [s1 appendString:@"toto"], it call NSMutableString
appendString: method but only because GSMString inherit from NSMutableString.
Same thing for s2.
What I don't understand:
GSWElementIDString was working well with no ivar and without
implementing -initXXX3. Why ? In this logic, it wasn't possible because it
shouldn't have ivars nor -initXXX methods.
You can see the code in gsweb/GSWeb.framework/GSWElementIDString.[hm]
>| To subclass NSMutableString, you should be inheriting from NSMutableString
>and implementing
>| (at least) -replaceCharactersInRange:withString:, -length,
>-characterAtindex:
>|
>| As the code stands now, you also have to implement the designated
>initialisers -
>| -initWithCharactersNoCopy:length:freeWhenDone:
>| -initWithCStringNoCopy:length:freeWhenDone:
>| -initWithCapacity:
I can do this but why should I reimplement GSMString (for example) as I only
want a working MutableString which differ only by the class name and few added
methods ? I can do this by subsclassing GSMString but it's not the right way
for portability.
Sorry to ask newbie questions :-)
Manuel
--