ibireme / YYCategories

A set of useful categories for Foundation and UIKit.
MIT License
826 stars 218 forks source link

为什么要这样写? #15

Closed AaronZhang2015 closed 8 years ago

AaronZhang2015 commented 8 years ago

if (target.events & controlEvents) { UIControlEvents newEvent = target.events & (~controlEvents); if (newEvent) { [self removeTarget:target action:@selector(invoke:) forControlEvents:target.events]; target.events = newEvent; [self addTarget:target action:@selector(invoke:) forControlEvents:target.events]; } else { [self removeTarget:target action:@selector(invoke:) forControlEvents:target.events]; [removes addObject:target]; } }

第一个if不是已经判断是不是同一个事件了么,第二行是什么意思

ibireme commented 8 years ago

events 是按位来处理的。 第一行判断的是,当前 events 是否和 controlEvents 有交集,第二行是把 controlEvents 排除掉,还剩几个 event。