Skip to content
New issue

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

分类与扩展的区别? #27

Open
tbfungeek opened this issue Jan 5, 2020 · 0 comments
Open

分类与扩展的区别? #27

tbfungeek opened this issue Jan 5, 2020 · 0 comments

Comments

@tbfungeek
Copy link
Owner

tbfungeek commented Jan 5, 2020

  • 分类是运行时决议的,扩展是编译时决议的
  • 分类不可以添加实例变量,扩展可以添加实例变量
  • 分类可以在没有源码的情况下为某个类添加方法,扩展只能寄生于宿主类的.m文件中,在编译期和头文件里的@interface以及实现文件里的@implement一起形成一个完整的类。伴随着类的产生而产生,也随着类的消失而消失。没有源码的情况下不能为某个类添加方法。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant