#import "ViewController.h" /* 匿名分类和分类的区别 1.匿名分类没有名字, 分类有名称 2.匿名分类不需要有对应的实现, 而分类需要有对应的实现 3.匿名分类可以声明属性, 也可以声明方法, 分类只能声明方法 */ /* @interface ViewController (NJ) //{ // double _height; //} - (void)run; // 分类中的@property只会生产getter/setter方法的声明, 不会生产实现以及私有的成员变量 @property(nonatomic, assign)double height; @end @implementation ViewController (NJ) - (void)run { } @end */ // 以后开发中但是是不需要暴露给外界的属性和方法都卸载匿名分类中 @interface ViewController () //{ // int _age; //} // 苹果推荐我们将属性写在匿名分类中(延展/ 类扩展) @property(nonatomic, weak)IBOutlet UILabel *lable; - (void)run; @end @implementation ViewController // 。。。。。。 @end
时间: 2024-12-22 12:38:10