C C++ Objectc 中define 与 typedef的区分  enum

#define kNotificationAppInstallSuccess @"ipa_install_success"

typedef int Age;
typedef enum
{
    SDWebImageRetryFailed = 1 << 0,  //  左移的作用相当于乘以2,右移相当于除以2
    SDWebImageLowPriority = 1 << 1,
    SDWebImageCacheMemoryOnly = 1 << 2   //1左移2位  1*2*2  结果为4
} SDWebImageOptions;

define的定义是用前面的代替后面的 kNotificationAppInstallSuccess 代替 @"ipa_install_success"在代码中使用

typedef  用后面的代替前面的使用  Age 代替 int类型进行使用  SDWebImageOptions 代替前面那个枚举类型


  1. enum  direction{up,down,left=9,right};

我们定义了一个枚举类型direction,因为up 在序列的第一位,所以编译器将它赋值为0,down在其后面所以赋值为1;对于left,我们赋值为9,后面是right,所以它的值是10。


原文地址:https://www.cnblogs.com/cnsec/p/11515856.html