首页 > 其他 > 详细

类扩展

时间:2015-07-10 02:02:36      阅读:173      评论:0      收藏:0      [点我收藏+]
#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

 

类扩展

原文:http://www.cnblogs.com/cjpBlog/p/4634634.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!