斯坦福 IOS讲义 课件总结 一

1,引入文件,

#import <Foundation/Foundation.h>

IOS7 中可以这样写 @import Foundation; 

2,在.h文件引入的是公用的,在.m文件里面引用的是本类私有的。私有属性声明

@interface Card()

//在这里面声明

@property (strong) NSString *contents;

@end

3,strong 是保存对象在内存中,week相反,这两个词形容的是对象。

4,nonatomic,不涉及多线程,没有锁,所以快一点,。

5,系统默认的set,get方法。

 

@synthesize contents = _contents;

- (NSString *)contents

{

    return _contents;

}

- (void)setContents:(NSString *)contents

{

    _contents = contents;

}

6,@property (nonatomic) BOOL chosen;非对象类型不必用strong或week形容。

7,@property (nonatomic, getter=isChosen) BOOL chosen;改变取值方法名字。

8,- (int)match:(Card *)card;重写初始化方法。

9,初始化方法也可传参数。

- (int)match:(NSArray *)otherCards

{

int score = 0;

    if ([card.contents isEqualToString:self.contents]) {

        score = 1;

}

    return score;

}

posted @ 2014-07-12 13:20  管小木  阅读(260)  评论(0编辑  收藏  举报