My understanding is that instance variables should be accessed directly from inside the init
method. For example:
@interface ABC : NSObject
@property (strong, nonatomic) NSString *name;
@end
@implementation ABC
- (id)init
{
if ((self = [super init]) != nil)
{
_name = @"some name";
}
}
// another init example
- (id)initWithName:(NSString*)n
{
if ((self = [super init]) != nil)
{
_name = n;
}
}
@end
I am wondering about the _name
variable. In both init
examples, is _name
retained? For this example, I am using ARC.