Like I understand, @synthesize actually is generating the Getters and Setters. But what's @property then doing? Is it just setting up the parameters for that cool @synthesize magic function?
+2
A:
You write @property in header file
@property float value;
is equivalent to:
- (float)value;
- (void)setValue:(float)newValue;
It get information for OTHER classes, that your class has this methods
@synthesize phisicaly CREATE these methods in class implementation
oxigen
2009-04-30 11:17:10
+3
A:
@property
declares the name as a property. This means, it will be accessible via the dot syntax (object.value
).
@synthetize
can be seen as a macro, that creates the getter and setter methods. It is useful to know that you can override those methods, even if you type have the @synthetize
in place.
pgb
2009-04-30 11:34:45
It's important to note, however, that methods declared as usual are accessible via the dot syntax, not just properties (though I would never recommend using dot syntax for anything that isn't a getter or setter). And, more importantly, without @synthesize, your properties aren't accessible by *any* method. If you use @property without @synthesize, it's exactly like declaring getter and setter methods, but never implementing them.
andyvn22
2009-08-09 18:31:05
+2
A:
@property
declares getter and/or setter
@synthesize
implements them.
mouviciel
2009-04-30 15:07:12