Why do we have to do [MyClass class] in Objective-C?

后端 未结 8 1633
一向
一向 2020-12-13 00:01

In Objective-C, you can invoke class methods with:

[MyClass aClassMethod];

And you can query an instance\'s kind with:

[som         


        
8条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-13 00:45

    MyClass is not of type Class.

    [MyClass class] is of type Class.

    If you are familiar with Java, the concept is the same.

    java.lang.String is not of type java.lang.Class

    java.lang.String.getClass() is of type java.lang.Class

提交回复
热议问题