IT English Collection(23)of Declared property

来源:互联网 发布:weka bp神经网络算法 编辑:程序博客网 时间:2024/05/16 10:05

1 前言

    本节我们主要介绍了一下属性声明的方式和与存储方法的关系。

    转载请注明转自:http://blog.csdn.net/developer_zhang

2 详述

2.1 原文

    A declared property provides asyntacticalshorthand 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 thestoragesemantics 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 typespecification 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 (orinform 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 thespecification 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 结语

    以上是所有内容,希望对大家有所帮助。

原创粉丝点击