Tuesday, March 15, 2011

What describes @property(.....) best? What's that actually good for?

All I think to know is, that it marks a property "public". And it creates setters and getters automatically. But when I don't have that, are my properties private?

What's the name of this "technology"? Why's there an @ in front of "property"?

From stackoverflow
  • My understanding is that the @ infront of property makes it a compiler directive. It tells the compiler to do things. In this case it creates tells the compiler how to create the getter and setter methods for the member variable. You could do this manually of course, but this is there so that the compiler can do it for you.

  • @property () type prop_name is just a signal to compiler to create two methods:

    -(type) propName;

    and

    -(void) setPropName; // Not created for readonly properties

    In objective-C all methods are public. Let is why all properties are public too

0 comments:

Post a Comment