Objective-C中的对象是什么? [英] What is an object in Objective-C?

查看:97
本文介绍了Objective-C中的对象是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我以为我对一个对象是个好主意..但是我错了.谁能解释什么是物体?还是我在编程时应该如何看待它? 请帮助我理解.

I thought I had a pretty good idea of what an object is.. but I was wrong. Could anyone explain what an object is? Or how I should think of it when programming? Please help me understand.

我知道它不是指针..那么代码行中的对象到底是什么..

I know it's not the pointer .. so what exactly is the object in a line of code ..

推荐答案

从概念上讲,在OOP中,对象是类的特定实例.类定义了特定类型对象的信息和动作.典型的例子是Car类,它可能具有颜色"属性,并且可以驱动"或停放".这些定义了什么是汽车.对象就是那个的实例.世界上有数百万辆汽车,但只有汽车的一种定义

Conceptually in OOP, an object is a certain instance of a class. A class defines the information and actions for a certain type of object. The quintessential example is of a Car class, that maybe holds a "colour" property and can "drive" or "park". These define what a Car is. Objects are instances of that. There are millions of cars in the world, but only one definition of Car

现在,这是常规的OOP视图.基于消息发送的概念,Objective-C具有相当纯净的OOP模型.消息发送是这样执行的:[obj消息].本质上,Obj-C中的对象是任何响应消息的对象.这意味着甚至类都是对象.如果您需要更详细的描述,我的博客文章应该有所帮助: http://pilky.me/view/21

Now, that is the general OOP view. Objective-C has a rather pure OOP model, based on the concept of message sending. Message sending is performed as so: [obj message]. Essentially, an object in Obj-C is anything that responds to a message. This means that even classes are objects. If you want a more detailed description, this blog post of mine should help: http://pilky.me/view/21

这篇关于Objective-C中的对象是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆