1.枚舉類型
//推薦的定義枚舉類型的方式
typedef NS_ENUM(NSInteger, RWTLeftMenuTopItemType) {
RWTLeftMenuTopItemMain,
RWTLeftMenuTopItemShows,
RWTLeftMenuTopItemSchedule
};
typedef NS_ENUM(NSInteger, RWTGlobalConstants) {
RWTPinSizeMin = 1,
RWTPinSizeMax = 5,
RWTPinCountMin = 100,
RWTPinCountMax = 500,
};
//不推薦的方式
enum GlobalConstants {
kMaxPinSize = 5,
kMaxPinCount = 500,
};
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
2.結構體
//1.定義一個Sample結構體
struct Sample {
int a;
int b;
int c;
};
//初始化的時候,可以這樣賦值
struct Sample sampleStruct = {1, 2, 1};
NSLog(@"sampleStruct中的值%d",sampleStruct.a );
//2 .定義一個Sample結構體
struct Sample{
int a;
int b;
int c;
}sampleStruct;
typedef struct Sample MySampleStruct;
//以後用這個結構體,就可以直接用MySampleStruct去定義了
MySampleStruct samDefineStructVarible = {1,2,1};
samDefineStructVarible.a = 1;
samDefineStructVarible.b =2;
samDefineStructVarible.c = 3;
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23