Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Understanding Objective c enum declaration

From iPhone UIControl

UIControlEventAllTouchEvents      = 0x00000FFF,
UIControlEventAllEditingEvents    = 0x000F0000,
UIControlEventApplicationReserved = 0x0F000000,
UIControlEventSystemReserved      = 0xF0000000,
UIControlEventAllEvents           = 0xFFFFFFFF

Now I assume the UIControlEventApplication is the 'range' I can use to specify custom control events, but I have no idea how to do it properly. Only if I assign 0xF0000000 the control event will correctly fire. If I assign anything else (0xF0000001) the control event fires when it's not supposed to.

Some clarification:

enum {
    UIBPMPickerControlEventBeginUpdate = 0x0F000000,
    UIBPMPickerControlEventEndUpdate = // Which value do I use here?

};

My assumption of it being a range is based on the docs. Which say:

I assume this because the docs say: A range of control-event values available for application use.

Could anyone help me understand the type of enum declaration used in UIControl?

like image 373
klaaspieter Avatar asked Feb 12 '26 03:02

klaaspieter


1 Answers

I would think 0x0F000000 is the 4 bits you have at your disposal for creating your own control events.

0x0F000000 = 00001111 00000000 00000000 00000000

So any combination of:

0x00000001<<27 = 00001000 00000000 00000000 00000000
0x00000001<<26 = 00000100 00000000 00000000 00000000
0x00000001<<25 = 00000010 00000000 00000000 00000000
0x00000001<<24 = 00000001 00000000 00000000 00000000

You can of course OR these together to create new ones:

0x00000001<<24 | 0x00000001<<25 = 00000011 00000000 00000000 00000000

So in your example:

enum {
    UIBPMPickerControlEventBeginUpdate = 0x00000001<<24,
    UIBPMPickerControlEventEndUpdate = 0x00000001<<25, ...
};
like image 79
monowerker Avatar answered Feb 15 '26 01:02

monowerker



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!