c - bitwise OR in iOS -
enum { uiviewanimationoptionlayoutsubviews = 1 << 0, uiviewanimationoptionallowuserinteraction = 1 << 1, uiviewanimationoptionbeginfromcurrentstate = 1 << 2, uiviewanimationoptionrepeat = 1 << 3, uiviewanimationoptionautoreverse = 1 << 4, uiviewanimationoptionoverrideinheritedduration = 1 << 5, uiviewanimationoptionoverrideinheritedcurve = 1 << 6, uiviewanimationoptionallowanimatedcontent = 1 << 7, uiviewanimationoptionshowhidetransitionviews = 1 << 8, uiviewanimationoptioncurveeaseinout = 0 << 16, uiviewanimationoptioncurveeasein = 1 << 16, uiviewanimationoptioncurveeaseout = 2 << 16, uiviewanimationoptioncurvelinear = 3 << 16, uiviewanimationoptiontransitionnone = 0 << 20, uiviewanimationoptiontransitionflipfromleft = 1 << 20, uiviewanimationoptiontransitionflipfromright = 2 << 20, uiviewanimationoptiontransitioncurlup = 3 << 20, uiviewanimationoptiontransitioncurldown = 4 << 20, }; typedef nsuinteger uiviewanimationoptions;
what means expression: uiviewanimationoptionrepeat | uiviewanimationoptionautoreverse
.
value of uiviewanimationoptionrepeat equal 8(in bin 1000), uiviewanimationoptionautoreverse equal 16(in bin 10000). expression uiviewanimationoptionrepeat | uiviewanimationoptionautoreverse
should generate think 16(bin 10000) -> uiviewanimationoptionreverse.
uiviewanimationoptionrepeat | uiviewanimationoptionautoreverse
known "mask".
if have variable of type uiviewanimationoptions
, say:
uiviewanimationoptions a;
you can apply mask this:
bool b = && (uiviewanimationoptionrepeat | uiviewanimationoptionautoreverse)
to determine if a
"contains" either flags. if
a == 0x0000001;
then
b == false;
if
a == 0x0101001; //-- arbitrary mask
then
b == true;
so not interested in uiviewanimationoptionrepeat | uiviewanimationoptionautoreverse
evaluates to, in result of logically and-ing value of type flags interested in checking.
Comments
Post a Comment