?写法一(推荐这个):
typedef NS_ENUM(uint32_t, JL_WATCH_SETTING_TEST) {
JL_WATCH_SETTING_TEST1 = 1,
JL_WATCH_SETTING_TEST2 = 1 << 1,
JL_WATCH_SETTING_TEST3 = 1 << 2,
};
NSLog(@"JL_WATCH_SETTING_TEST, %d", t1);
NSLog(@"JL_WATCH_SETTING_TEST, %d", t2);
NSLog(@"JL_WATCH_SETTING_TEST, %d", t3);
NSLog(@"JL_WATCH_SETTING_TEST, %d", t1|t2|t3);
2021-12-07 14:00:32.372985+0800 Test[14450:467863] JL_WATCH_SETTING_TEST, 1
2021-12-07 14:00:32.373128+0800 Test[14450:467863] JL_WATCH_SETTING_TEST, 2
2021-12-07 14:00:32.373489+0800 Test[14450:467863] JL_WATCH_SETTING_TEST, 4
2021-12-07 14:00:32.373907+0800 Test[14450:467863] JL_WATCH_SETTING_TEST, 7
写法二:
typedef NS_ENUM(uint32_t, JL_WATCH_SETTING) {
JL_WATCH_SETTING_SENSOR_FUNC = 0x0002,
JL_WATCH_SETTING_SEDENTARY_REMIND = 0x0004,
JL_WATCH_SETTING_CONTINUOUS_HEARTRATE_MEASUREMENT = 0x0008,
JL_WATCH_SETTING_EXERCISE_HEARTRATE_REMINDER = 0x0010,
JL_WATCH_SETTING_AUTOMATIC_PRESSURE_DETECTION = 0x0020,
JL_WATCH_SETTING_SLEEP_DETECTION = 0x0040,
JL_WATCH_SETTING_FALL_DETECTION = 0x0080,
JL_WATCH_SETTING_LIFTWRIST_DETECTION = 0x0100,
JL_WATCH_SETTING_PERSONAL_INFO = 0x0200,
JL_WATCH_SETTING_BLUETOOTH_DISCONECTED_REMINDER = 0x0400,
};
JL_WATCH_SETTING s1 = JL_WATCH_SETTING_SENSOR_FUNC;
JL_WATCH_SETTING s2 = JL_WATCH_SETTING_SEDENTARY_REMIND;
JL_WATCH_SETTING s3 = JL_WATCH_SETTING_CONTINUOUS_HEARTRATE_MEASUREMENT;
JL_WATCH_SETTING s4 = JL_WATCH_SETTING_BLUETOOTH_DISCONECTED_REMINDER;
NSLog(@"JL_WATCH_SETTING, %d", s1);
NSLog(@"JL_WATCH_SETTING, %d", s2);
NSLog(@"JL_WATCH_SETTING, %d", s3);
NSLog(@"JL_WATCH_SETTING, %d", s4);
NSLog(@"JL_WATCH_SETTING, %d", s1|s2|s3|s4);
2021-12-07 14:00:32.372376+0800 Test[14450:467863] JL_WATCH_SETTING, 2
2021-12-07 14:00:32.372496+0800 Test[14450:467863] JL_WATCH_SETTING, 4
2021-12-07 14:00:32.372628+0800 Test[14450:467863] JL_WATCH_SETTING, 8
2021-12-07 14:00:32.372747+0800 Test[14450:467863] JL_WATCH_SETTING, 1024
2021-12-07 14:00:32.372863+0800 Test[14450:467863] JL_WATCH_SETTING, 1038
|