What describes @property (.....) better? What is it really useful for?

All I think to know is that it stands for the "public" property. And it automatically creates setters and getters. But when I don’t have it, my properties are closed?

What is the name of this "technology"? Why is there @ before the "property"?

0
source share
2 answers

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

- (type) propName;

and

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

In objective-C, all methods are publicly available. Therefore, all properties are publicly available.

+1
source

I understand that the @infront properties make it a compiler directive. It tells the compiler to do something. In this case, he creates a command to the compiler how to create the getter and setter methods for the member variable. You can do it manually, of course, but it is so that the compiler can do it for you.

0
source

Source: https://habr.com/ru/post/885558/


All Articles