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 结语

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值