gpt4 book ai didi

iphone - isa 实例变量到底是什么?

转载 作者:搜寻专家 更新时间:2023-10-30 19:52:26 25 4
gpt4 key购买 nike

在 NSObject Class Reference 中,他们讨论了一个“isa 实例变量”

is initialized to a data structure that describes the class

谁能解释一下关于这个 isa 实例变量我应该知道些什么?那有什么用?是什么意思?听起来很规范,比如 DIN、ISO 等;知道那是什么吗?

最佳答案

用于确定一个类的继承路径。更正式地说:

When a new object is created, it is allocated memory space and its data in the form of its instance variables are initialised. Every object has at least one instance variable (inherited from NSObject) called isa, which is initialized to refer to the object's class. Through this reference, access is also afforded to classes in the object's inheritance path. - Objective-C GNUstep Base Programming Manual: Objective-C

isa 这个名字来自 IS-A 的 OOP 概念,它只是两个对象之间的关系,如下所示:

A dog IS-A mammal.
A car IS-A vehicle.

因此 isa 实例变量会很有帮助,因为它可以告诉您您的类在其继承层次结构中具有哪些 IS-A 关系。

关于iphone - isa 实例变量到底是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/789103/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com