码迷,mamicode.com
首页 > 其他好文 > 详细

类扩展

时间:2015-07-10 02:05:10      阅读:96      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!