Objective-C 中的类是对象吗?
好的,所以我明白对象是必须分配和初始化的类的实例,但是类本身是对象吗?
我知道当你创建一个新类时,它是其他东西的实例,比如 NSObject。那么,如果这使它成为一个类,那么对象不仅可以保存变量和方法,还可以保存其他对象,对吗?
抱歉,这可能真的很基础,但是我正在读两本关于 cocoa 和 xcode 的书,这一点有点不清楚(可能是因为我缺乏其他语言的经验)。
okay, so I understand that an object is an instance of a class that must be allocated and initialized, but are classes themselves objects?
I know when you create a new class it is an instance of something else, like NSObject. So, if this makes it a class, then objects can hold not only variables and methods, but other objects as well, right?
Sorry, this is probably really basic, but I am reading two books about cocoa and xcode and this point is a little unclear (probably because of my lack of experience in other languages).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这里是 Greg Parker 引用的对此事的一个很好的解释
:
更多有趣的读物:
了解 Objective-C 运行时科林·惠勒
(搜索标题为“因此类定义对象...”的段落)
什么是Objective-C 中的元类? 作者:Matt Gallagher
Here is a pretty good explanation of the matter by Greg Parker
Quoting:
Further interesting reads:
Understanding the Objective-C Runtime by Colin Wheeler
(search for paragraph titled "So Classes define objects…")
What is a meta-class in Objective-C? by Matt Gallagher