Autorelease and properties
- by ganuke
I have few questions to ask about the following class
#import <Cocoa/Cocoa.h>
@interface SomeObject {
NSString *title;
}
@property (retain) NSString *title;
@end
implementation SomeObject
@synthesize title;
-(id)init {
if (self=[super init])
{
self.title=[NSString stringWithFormat:@"allyouneed"];
}
return self;
}
-(void)testMethod{
self.title=[[NSString alloc] init] ;
}
-(void)dealloc {
self.title=nil;
[super dealloc];
}
In the .h file do we need to declare the title and sub when we add the property. is it not enough to add the @property (retain) NSString *title; line.
2.Do i need to autorelease both assignment to title in the init and testMethod. if So why?
Can some one explain these things to me.