Monday, September 19, 2011

Do you know Objective-c? Properties

I started publishing posts by forgiving a feature of Objective-C really usefull for our application development allow us to generate automatically getters/setters. Also we usually have to think that our code have to be straightforward and it could be generalized. Properties are a kind of virtual member variables which offer us all we have said. This is what it look without use properties:


After we use properties in our code, it seems like this:


The word "retain"in parenthesis the setter function: it should retain the input value. Rest of the line specifies type and name of the property. After this, the class definition as follow:


We can use setter an getter methods which are generate by the @synthesize directive. This directive is used to instantiate the property Also we use the dot syntax to set or get a value as we used.
With this example, we see properties are so powerful feature to use in our software developer. Next post will explain the attributes that a property can be have.


No comments: