Effective Objective-C 2.0 学习第一天

重要知识点个人理解记录

第一条:OC 是消息结构语言,运行时解析,编译时不care

第二条:头文件引入尽量不要再.h文件中(编译费事),哪里用到哪里导入,一般在.m中导入。不要忘记@class可以在.h文件中声明。

第三条:多用简化语法,例如 NSArray *a = @[@"x",@"xx"];对于可变数组 [@[@"s",@"ss"] mutableCopy];

第四条:少用#define定义常量。 static NSString *const xxx = @"222";

.h文件

#import "BaseViewController.h"

static const int kWidth = 3;

static const int kHigh ;

extern NSString *const ConstKey;

@interface ConstViewController : BaseViewController

@end

 

 .m文件

#import "ConstViewController.h"

 const int kHight = 100;

NSString *const ConstKey = @"111";

@interface ConstViewController ()

@end

@implementation ConstViewController

 - (void)viewDidLoad {

    [super viewDidLoad];

}

- (void)didReceiveMemoryWarning {

    [super didReceiveMemoryWarning];

}

@end

 

posted on 2015-07-19 22:56  yang_M  阅读(116)  评论(0)    收藏  举报