[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: lost in gnustep first steps
From: |
David Ayers |
Subject: |
Re: lost in gnustep first steps |
Date: |
Thu, 05 Jun 2003 11:01:30 +0200 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4b) Gecko/20030507 |
@interface Dico: NSObject
{
NSMutableString *egy;
}
+ (id) new;
- (void) setEgy: one;
@end
- (id) init
{
if( (self = [super init]) )
{
egy = @"";
May I point out that even though the instance variable is declared to
hold a mutable string, that this assignent actually sets it to an
NSString. The compiler should have warned about this also. To get a
mutable string you should try:
egy = [NSMutableString new];
void main(void)
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
Dico *szotar = [[Dico alloc] init];
[szotar setEgy: @"nagzo ddf"];
and either [szotar setEgy: [NSMutableString stringWithString: @"nagro
ddf"]];
or [szotar addEgy: @"nagro ddf"];
and implement
- (void)addEgy:(NSString *)addition
{
[egy appendString: addition];
}
On the other hand, I must also admit that your code samples didn't seem
to reflect your stated intentions, and that Pascal's reply seems better
focused at your expressed intent.
May I suggest the following tutorial on some of the basic GNUstep
classes, such as:
NSString / NSMutableString
NSArray / NSMutableArray
NSDictionary / NSMutableDictionary
http://www.gnustep.it/nicola/Tutorials/BasicClasses/
Cheers,
David