@property @synthesize [英] @property @synthesize
问题描述
在Xcode中做什么 @synthesize
和 @property
做什么?请以非常简单的方式提供解释?
What do @synthesize
and @property
do in Xcode? Please provide an explanation in really simple terms?
推荐答案
您要求简单的条款:
@property 在
类标题中声明属性
@property declares a property in your class header
@property (nonatomic, retain) NSString *myString;
@synthesize 为您的房产创建您的setter和
getter(访问者
方法)
@synthesize creates your setter and getter for your property (accessor methods)
如果没有合成,你必须写
你自己的setter和getter
实现,比如getMyString或
setMyString(大写你的属性的第一个
字符)
Without synthesize you have to write your own setter and getter implemention, like getMyString or setMyString (capitalize the first character of your property)
Sam:只是一个建议: http://www.cocoadevcentral.com/d/learn_objectivec/ 是一个非常可靠的资源,可以学习属性等基础知识。
Sam: Just an advice: http://www.cocoadevcentral.com/d/learn_objectivec/ is a pretty solid resource to learn about basics like properties.
祝你好运!
这篇关于@property @synthesize的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!