1, introduction of files,
#import <Foundation/Foundation.h>
IOS7 can be written in this way @import Foundation;
2, introduced in. h file is common, in. m files are referred to this class is private. Private property Declaration
@interface Card()
Declare it in this area
@property (Strong) nsstring *contents;
@end
3,strong is to save the object in memory, week instead, these two words describe the object.
4,nonatomic, does not involve multi-threading, no locks, so hurry a little.
5, the system default Set,get method.
@synthesize contents = _contents;
-(NSString *) Contents
{
return _contents;
}
-(void) setcontents: (nsstring *) Contents
{
_contents = contents;
}
6,@property (nonatomic) BOOL chosen; Non-object types do not have to be described by strong or week.
7,@property (nonatomic, Getter=ischosen) BOOL chosen; Change the value method name.
8,-(int) match: (card *) Card; override initialization method.
9, the initialization method can also pass parameters.
-(int) match: (nsarray *) othercards
{
int score = 0;
If ([card.contents isequaltostring:self. Contents]) {
score = 1;
}
return score;
}