We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
感觉这里是写反了,首先 类可以调用实例定义的方法,当然必须得是NSObject中定义的实例方法,例如[ClassA copy], Class调用了实例方法copy,只是调用没有意义,IMP中的id传的是class,能调用的原因是因为类的元类的superClass最终指向的是NSObject(也就是实例的isa最终指向的),也就是文章中发的那个图,所以是能找到对应的实例方法。 实例调用class方法严格来说也不正确,因为你调用的[[a class] func],调用func的其实是[a class],也就是a的class而并非实例a
The text was updated successfully, but these errors were encountered:
No branches or pull requests
------原文-----
类方法
类方法中不能直接调用对象方法
实例方法:
实例方法中也可以调用类方法(通过类名)
感觉这里是写反了,首先
类可以调用实例定义的方法,当然必须得是NSObject中定义的实例方法,例如[ClassA copy], Class调用了实例方法copy,只是调用没有意义,IMP中的id传的是class,能调用的原因是因为类的元类的superClass最终指向的是NSObject(也就是实例的isa最终指向的),也就是文章中发的那个图,所以是能找到对应的实例方法。
实例调用class方法严格来说也不正确,因为你调用的[[a class] func],调用func的其实是[a class],也就是a的class而并非实例a
The text was updated successfully, but these errors were encountered: