Doing a lot of Objective C lately, thought it worthwhile to write a few key differences with Actionscript. To begin with today – getters and setters!
Properties in Objective C are automatically given setters and getters eg:
@property (strong,nonatomic) NSString *name;
is automatically given:
the getter:
-(NSString *)name
{
return _name;
}
the setter:
-(void)setName:(NSString *)name
{
_name = name;
}
You can replace these in your code. If you replace both, you need to add the line:
@synthesize name = _name;
Leave a comment