什么最能描述@property(.....)?那实际上有什么用? [英] What describes @property(.....) best? What's that actually good for?
问题描述
我想知道的是,它标记了一个"public"属性.并且它会自动创建setter和getter.但是当我没有那个属性时,我的财产是私有的吗?
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"?
推荐答案
@property()类型prop_name只是向编译器创建两个方法的信号:
@property () type prop_name is just a signal to compiler to create two methods:
-(type)propName;
-(type) propName;
和
-(void)setPropName; //不是为只读属性创建的
-(void) setPropName; // Not created for readonly properties
在Objective-C中,所有方法都是公开的.这就是为什么所有属性也都公开的原因
In objective-C all methods are public. Let is why all properties are public too
这篇关于什么最能描述@property(.....)?那实际上有什么用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!