面向对象的几个概念

■ A class is a structure that represents an object’s type. An object refers to its class to
get various information about itself, particularly what code to run to handle each
action. Simple programs might have a handful of classes; moderately complex ones
will have a couple of dozen. Objective- C style encourages developers to capitalize
class names.
■ An object is structure containing values and a hidden pointer to its class. Running
programs typically have hundreds or thousands of objects. Objective- C variables that
refer to objects are typically not capitalized.
■ Instance is another word for “object.” For example, a circle object can also be
called an instance of class Circle.
■ A message is an action that an object can perform. This is what you send to an object
to tell it to do something. In the [shape draw] code, the draw message is sent to the
shape object to tell it to draw itself. When an object receives a message, its class is
consulted to find the proper code to run.
■ A method is code that runs in response to a message. A message, such as draw, can
invoke different methods depending on the class of the object.
■ The method dispatcher is the mechanism used by Objective- C to divine which method
will be executed in response to a particular message. We’ll get out our shovels and dig
a lot more into the Objective- C method dispatch mechanism in the next chapter.

 

另外适用于object-c的:

The interface is the description of the features provided by a class of objects. For
example, the interface for class Circle declares that circles can accept the draw
message.

The implementation is the code that makes the interface work. In our examples,
the implementation for the circle object holds the code for drawing a circle on the
screen. When you send the draw message to a circle object, you don’t know or care
how the function works, just that it draws a circle on the screen.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值