While reading about classes in Objective-C I found that in some cases people advice that when implementing the init
method to do it as:
- (id) init {
if ( self = [super init] ) {
...
}
return self;
}
While others don't refer this. Which one is correct one?
Also, when defining setters most of the times they simply consist in an assignment but sometimes they appear as:
- (void) setCaption: (NSString*)input {
[caption autorelease];
[input retain];
caption = input;
}
Once again, which one is the best approach? Does ARC has some effect on this? If I use ARC, I don't need to use autorelease
as above?
thanks!