I’m wondering how ARC knows how to work when I create variables without @property like in this case:
@interface MyClass: NSObject
{
NSString *name;
}
-(NSString*)name;
-(void)setName:(NSString*)the_name;
have I to use __strong keyword like in this code? :
@interface MyClass : NSObject
{
NSString __strong *name;
}
Or I have to write accessor methods in this way ?:
-(void)setName:(NSString*)the_name{
name = __strong the_name;
}
No, you do not need to do anything special:
__strongkeyword is implied when there is no ARC keyword.EDIT You do not need to use
__strongin the setter either: ARC knows to retainthe_name, becausenameis already a__strongreference.