objective c - How can I typecast the result of ([theEvent modifierFlags] & NSCommandKeyMask) into a BOOL? -
i have had code has been broken, , wasn't until realized isn't valid:
bool alwaysdrawgraphic = ([theevent modifierflags] & nsalternatekeymask); if( alwaysdrawgraphic ) { nslog(@"hey"); } because result of bitwise operation & doesn't return bool.
so figured use lldb po ([theevent modifierflags] & nsalternatekeymask), error:
error: use of undeclared identifier 'nsalternatekeymask' error: 1 errors parsing expression so tried nslog value when have command key pressed,
nslog(@"%lu", ([theevent modifierflags] & nscommandkeymask));
xcode corrected me , let me know value unsigned long. when logs out, lu: 1048576
if command key isn't pressed, prints 0, expect
so question is, value 1048576 getting?
, how can typecast bool can re-use several times within same method?
you have check if result 0 or 1 after being masked
bool alwaysdrawgraphic = ([theevent modifierflags] & nsalternatekeymask) != 0; 1048576 hex 0x00100000 bit position of nscommandkeymask
Comments
Post a Comment