你好。我想声明一个结构体 或者一个枚举- typedef enum {man,woman,yao}Sex;
- @interface Person : NSObject
- {
- NSString *_pName;
- Sex *_sex;//<span style="line-height: 30.8px; background-color: rgb(255, 255, 255);">这里我Sex *sex; 和Sex sex; 有什么区别???</span>
- int _age;
- float _high;
- Goods *_food;
- }
- @property(nonatomic,assign)int age;
- @property(nonatomic,assign) float high;
- @property(nonatomic,retain)NSString * name;
- @property(nonatomic,assign)Sex * sex;
复制代码 还有定义结构体的时候 如果想用SET方法定义一个变量的时候。
- #import <Foundation/Foundation.h>
- typedef struct{
- int year;
- int month;
- int day;
- }ProduceDate;
- @interface Goods : NSObject
- {
- NSString *_name;
- float _price;
- float _weight;
- NSString *_picture;
- ProduceDate* _birth;//这里是不是必须就要加* 要不然主函数就无法定义变量值???
- NSString * _expireDa;
-
- }
- @property(nonatomic,retain) NSString * name;
- @property(nonatomic,assign) float price;
- @property (nonatomic,assign)float weight;
- @property(nonatomic,retain) NSString * picture;
- @property(nonatomic,assign) ProduceDate* birth;
- @end
复制代码
|
|