第一天

来源:互联网 发布:js indexof 判断 编辑:程序博客网 时间:2024/06/05 01:47

//.h方法中

#import <Foundation/Foundation.h>


@interface People : NSObject
{
    float weight;
    float height;
}
//@property是一个描\描述命令,他的意思是对某一个变量进行一下描述,,描述的内容是,告诉编译器在底层声明并实现一下这个变量的set和get方法.
//nonatomic:关于线程安全的参数
//assign基本类型的变量一般用assign

@property(nonatomic,assign)float weight;//基本类型用assign
@property float height;
//字符串类型的变量描述用copy
@property(nonatomic,copy) NSString *name;//NNString用copy

//既然用了@property声明了一个变量,就要在.m中加上@synthesize这个变量

@end


//.m方法中


#import "People.h"

@implementation People
@synthesize height;
@synthesize weight;
@synthesize name;
//@synthesize是一个指定命令,指定的是描述的是哪一个变量名

//@synthesize height = _height;以前是这样声明指定的,对于现在的Xcode4.0之后,就不用这样写了,上边的@synthesize height;@synthesize weight;@synthesize name;都不用写了

@end

0 0