objective-c - 在一个父类中 self 是其子类的对象.
黄舟
黄舟 2017-05-02 09:18:51
0
2
687


在一个类的父类中什么情况下 self 可以表示为它的子类的对象?self 不应该是在哪个类中表示那个类的对象吗?

黄舟
黄舟

人生最曼妙的风景,竟是内心的淡定与从容!

reply all(2)
某草草

The self keyword in iOS has many meanings and rules. It does not mean which class of object it refers to in which class the subject understands! First of all, correct this problem. Self represents the object of the current class. In the picture posted by the subject, the type of the current object is displayed, which can be understood as calling [self class]. If the current class and all parent classes have not overridden this method, Then the class method of NSObject will be called.

In addition, the self keyword in OC has different meanings and functions in different scopes. In instance methods, self represents the first address of the object, while in class methods, self represents the current Class. In OC, Class is also an object, so self is different,

仅有的幸福

When that object is really a subclass object

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template