OK, I reply to myself. I just found a similar example and this is the result :
Code:
#import <Foundation/Foundation.h>
@interface Person : NSObject
{
NSString *person;
}
-(void) SetPersonName : (NSString*) name;
//-(NSString) GetPersonName;
@end
@implementation Person
-(void) SetPersonName : (NSString*) name;
{
[name retain];
//[person release]
person = name;
}
@end
int main (int argc, const char * argv[])
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
Person * testperson;
testperson = [Person alloc];
testperson = [testperson init];
NSString * nametogive = @"Louis Armstrong";
[testperson SetPersonName : nametogive];
[pool drain];
return 0;
}
Somehow I don't get any error, I have to verify if it actually prints "Louis Armstrong". I'll let you know. One question. I don't get this passage:
Code:
-(void) SetPersonName : (NSString*) name;
{
[name retain];
//[person release]
person = name;
}
What is the "retain" doing ?
Thanks