What do @synthesize
and @property
do in Xcode? Please provide an explanation in really simple terms?
You asked for simple terms:
@property declares a property in your class header
@property (nonatomic, retain) NSString *myString;
@synthesize creates your setter and getter for your property (accessor methods)
Without synthesize you have to write your own setter and getter implemention, like getMyString or setMyString (capitalize the first character of your property)
Sam: Just an advice: http://www.cocoadevcentral.com/d/learn_objectivec/ is a pretty solid resource to learn about basics like properties.
Good Luck!
Properties and synthesized accessors are new features in Objective-C 2.0.
When you declare a @property
you declare somewhat an instance var. Then you @synthesize
accessor methods (i.e. getter and setter) for that property.
There are also @dynamic
accessors if you're interested.
You should really do your homework on this. Apple has nifty pdf for that.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With