Reputation: 35
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;
}
Upvotes: 1
Views: 304
Reputation: 726479
No, you do not need to do anything special: __strong
keyword is implied when there is no ARC keyword.
EDIT You do not need to use __strong
in the setter either: ARC knows to retain the_name
, because name
is already a __strong
reference.
Upvotes: 2