按位&,| 与 iOS 中二进制数赋值的枚举之间的关系

  1. 按位&,| 


2.NSSet这个容器是用来提高效率,当容器中的元素的顺序不重要时,NSSet封装hash排序等算法,可以将寻找该内存地址时间复杂度达到O(1)级别,或者常数级别;

按位 &

二进制相位对齐,一真或就真



按位 | 竖式运算

按位或是位运算的一种,是将两个数据的二进制表示右对齐后,按位进行运算,两个对应的二进制位中只要一个是1,结果对应位就是1

  1 | 1 = 1 , 1 | 0 = 1 , 0 | 1 = 1 , 0 | 0 = 0

  比如说十进制数53

  5 | 3

  先把它们换成二进制表示

  101 , 011

  按照刚才的规则:

  1 0 1

  | 0 1 1

  --------

  1 1 1


    UIUserNotificationTypeNone    = 0,      // the application may not present any UI upon a notification being received

二进制数ox0;

    UIUserNotificationTypeBadge   = 1 << 0, // the application may badge its icon upon a notification being received

二进制数ox1;

    UIUserNotificationTypeSound   = 1 << 1, // the application may play a sound upon a notification being received

二进制数ox10;

    UIUserNotificationTypeAlert   = 1 << 2, // the application may display an alert upon a notification being received

二进制数ox100;

//多个 枚举值

按位或的结果是111;这个二进制结果会返回给系统;

你可能感兴趣的:(按位&,| 与 iOS 中二进制数赋值的枚举之间的关系)