IT English Collection(16) of Message

来源:互联网 发布:js文本框失去焦点时 编辑:程序博客网 时间:2024/06/05 13:28

1 前言

    本文介绍了关于Objective-C中的消息机制,详情如下。

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

2 详述

2.1 原文

    A message is the name of a method, and any parametersassociated with it, that are sent to, andexecuted by, an object. To get an object to do something, you send it a message telling it to apply a method. In Objective-C, youspecify the object (known as the receiver of the method) and the message being sent to that object byenclosing the messageexpression inbrackets. For example, this message expression tells the myRectangle object to perform its display method:

[myRectangle display];

(The expression is followed by asemicolon (;) as is normal for any line of code in C.)

    The method name in a message serves to select a method implementation—when a message is sent, the runtime system selects the appropriate method from the receiver’srepertoire and invokes it. For this reason, method names in messages are often referred to as selectors.

    Methods can also take parameters, also called arguments. A message with a single argument affixes acolon (:) to the selector name and puts the parameter right after the colon. Thisconstruct is called a keyword; a keyword ends with a colon, and a parameter follows the colon. A method that takes multiple parameters has multiple keywords, each followed by a colon.

[myRectangle setLineWidth:0.25];
[myRectangle setWidth:20.0 height:50.0];

2.2 生词

associated with有关系;与相联系

execute['eksɪkjuːt] vt.实行;执行

specify['spesɪfaɪ] vt. 指定;详细说明

enclose[ɪn'kləʊz; en-] vt. 围绕;装入

expression[ɪk'spreʃ(ə)n; ek-] n. 表现,表示

bracket['brækɪt] n. 支架;括号

semicolon[,semɪ'kəʊlən; -'kəʊlɒn] n. 分号

appropriate[ə'prəʊprɪət] adj. 适当的

repertoire['repətwɑː] n. 全部节目;计算机指令系统

affixesn. [语] 词缀

colon['kəʊlən] n. 冒号

construct[kən'strʌkt] vt. 建造,构造

3 结语

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

原创粉丝点击