本文主要是介绍IT English Collection(23)of Declared property,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
1 前言
本节我们主要介绍了一下属性声明的方式和与存储方法的关系。
转载请注明转自:http://blog.csdn.net/developer_zhang
2 详述
2.1 原文
A declared property provides asyntactical shorthand for declaring a class’s accessor methods and,optionally, implementing them. You can declare a property anywhere in the method declaration list, which is in the interface of a class, or in the declaration of a protocol or category. You use the followingsyntax:
@property (<#attributes#>) <#type#> <#name#>;
You begin a property declaration with the keyword @property. You can then optionally provide aparenthesized set of property attributes that define thestorage semantics and other behaviors of the property. (Refer to the document thatdefinitively describes property lists for descriptions of these attributes.)
Each property declaration ends with a type specification and a name. For example:
@property(copy) NSString *title;
This syntax is equivalent to declaring the following accessor methods:
- (NSString *)title;
- (void)setTitle:(NSString *)newTitle;
In addition to declaring the accessor methods, you can instruct the compiler to synthesize implementations of them (or inform the compiler that your class will synthesize them at runtime).
You use the @synthesize statement in a class’s implementation block to tell the compiler to create implementations that match the specification you gave in the property declaration.
@interface MyClass : NSObject
{NSString *title;
}
@property(copy) NSString *title;
@end@implementation MyClass
@synthesize title;
@end
You use the @dynamic statement to tell the compiler to suppress a warning if it can’t find an implementation of accessor methods specified by an @property declaration.
@implementation MyClass
@dynamic title;
@end
2.2 生词
syntactical[sin'tæktikəl]adj. 句法的;依照句法的
shorthand['ʃɔːthænd]n. 速记;速记法
optionally ['ɔpʃənəli]adv. 随意地
syntax['sintæks]n. 语法;句法
parenthesize[pə'renθɪsaɪz] 将……加上括弧
storage['stɔːrɪdʒ]n. 存储;仓库
semantics[sɪ'mæntɪks]n. [语] 语义学;语义论
definitively['definitivli]adv. 决定性地;最后地
specification[,spesifi'keiʃən]n. 规格;说明书;详述
equivalent[ɪ'kwɪv(ə)l(ə)nt]adj. 等价的,相等的
instruct[ɪn'strʌkt]vt. 指导;通知;命令
synthesize['sɪnθəsaɪz]vt. 合成;综合
inform[ɪn'fɔːm]vt. 通知;告诉;
dynamic[daɪ'næmɪk]adj. 动态的;动力的
suppress[sə'pres]vt. 抑制;镇压;废止
specified['spesifaid]adj. 规定的;详细说明的
3 结语
以上是所有内容,希望对大家有所帮助。
这篇关于IT English Collection(23)of Declared property的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!