Does different iVar name change retain count when used with property
- by russell
Here is 2 code snapshot-
Class A:NSObject
{
NSMutableArray *a;
}
@property (retain) NSMutableArray *a;
@implementation
@synthesize a;
-(id)init
{
if(self=[super init])
{
a=[[NSMutableArray alloc] init];
}
}
@end
Class A:NSObject
{
NSMutableArray *_a;
}
@property (retain) NSMutableArray *a;
@implementation
@synthesize a=_a;
-(id)init
{
if(self=[super init])
{
_a=[[NSMutableArray alloc] init];
}
}
@end
Now what i need to know, is in both code instance variable assigned value directly rather than using accessor and retain count is 1? Or there is difference between them. Thanks.
And one more things, apple recommended not to use accessor in init/dealloc, but at the same time ask not to directly set iVar. So what is the best way to assign value of ivar in init()??