도대체
먼저 공식적인 해석을 보고 개인적인 이해를 말씀드리겠습니다.Every object is connected to the run-time system through itsisa instance variable, inherited from the NSObject class.isa identifies the object's class; it points to a structurethat's compiled from the class definition. Through isa, anobject can find whatever information it needs at run timesuch asits place in the inheritance hierarchy, the size and structure ofits instance variables, and the location of the methodimplementations it can perform in response to messages.
하나의 대상 (Object) 의 이사는 이 대상의 클래스 (Class) 를 가리키고, 이 대상의 클래스 (Class) 의 이사는 Metaclass를 가리킨다.이렇게 하면 상응하는 정적 방법과 변수를 찾을 수 있다.Objective-C는 실행할 때 동적입니다. 실행할 때 방법을 추가하거나 삭제하거나 반사를 사용할 수 있습니다.
클래스의 실례 대상의isa는 클래스를 가리킨다.클래스의isa는 이 클래스의metaclass를 가리킨다.클래스의 슈퍼class는 상위 클래스를 가리키며, 이 클래스가 루트라면 값은 NULL입니다.metaclass의isa는 루트 metaclass를 가리키고 이 metaclass가 루트 metaclass라면 자신을 가리킨다.metaclass의 슈퍼class는 부모 metaclass를 가리키고 이 metaclass가 루트 metaclass라면 이 metaclass에 대응하는 클래스를 가리킨다.
// objc.h
#if !OBJC_TYPES_DEFINED
/// An opaque type that represents an Objective-C class.
typedef struct objc_class *Class;
/// Represents an instance of a class.
struct objc_object {
Class isa OBJC_ISA_AVAILABILITY;
};
/// A pointer to an instance of a class.
typedef struct objc_object *id;
#endif
// NSObject.h
@interface NSObject {
Class isa OBJC_ISA_AVAILABILITY;
}
// objc_class
struct objc_class {
Class isa OBJC_ISA_AVAILABILITY;
#if !__OBJC2__
Class super_class OBJC2_UNAVAILABLE;
const char *name OBJC2_UNAVAILABLE;
long version OBJC2_UNAVAILABLE;
long info OBJC2_UNAVAILABLE;
long instance_size OBJC2_UNAVAILABLE;
struct objc_ivar_list *ivars OBJC2_UNAVAILABLE;
struct objc_method_list **methodLists OBJC2_UNAVAILABLE;
struct objc_cache *cache OBJC2_UNAVAILABLE;
struct objc_protocol_list *protocols OBJC2_UNAVAILABLE;
#endif
} OBJC2_UNAVAILABLE;
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
다양한 언어의 JSONJSON은 Javascript 표기법을 사용하여 데이터 구조를 레이아웃하는 데이터 형식입니다. 그러나 Javascript가 코드에서 이러한 구조를 나타낼 수 있는 유일한 언어는 아닙니다. 저는 일반적으로 '객체'{}...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.