PDA

View Full Version : @property ?




iFaisal
Apr 22, 2011, 08:23 AM
hello everyone ,

what is the different between set/get function and @property/@synthesize ?

is it just syntax code or not ? and what does mean ?



gnasher729
Apr 22, 2011, 09:05 AM
hello everyone ,

what is the different between set/get function and @property/@synthesize ?

is it just syntax code or not ? and what does mean ?

The Objective-C 2.0 language manual on Apple's web site will answer all these questions. And playing around with styles like you did is _very_ impolite.

Psilocybin
Apr 22, 2011, 02:06 PM
synthsize sets up its own get/set methods

jiminaus
Apr 22, 2011, 06:20 PM
At first we had to code our own getters and setters. There was no concept of a property in Objective-C 1.0, except by the convention that if a class had a method x and a method setX: then it could have been said to have property x.

Then Apple created Objective-C 2.0 and it introduced the @property and @synthesise directives, as well as the dot notation. And the number of getters and setters we had to write was reduced to near zero. And our getters and setters become correct in the face of concurrency (assuming no nonatomic) which set us up well for the days of multicore CPUs and GCD.

And the people programming in the land of Apple were happy. (Well generally, some have some valid objections to dot notation).

So yeah, it's just syntax. But I'd highly recommend you use it, unless you have strong reasons not to.

iFaisal
Apr 23, 2011, 04:19 PM
thank you everyone ... I'm understanding now what is the different . :)