Reference for numeric values of ObjC enums?
The UIKit docs list all of the enums for things like DatePicker style, but not their numeric values. Since we don't have those enums available to us (as far as I can tell), is there any way to look up their values?
They don't seem to line up the way you'd expect- for example, for DatePicker style, the docs list:
UIDatePickerStyleAutomatic A style indicating that the system picks the concrete style based on the current platform and date picker mode. UIDatePickerStyleCompact A style indicating that the date picker displays as a label that when tapped displays a calendar-style editor. UIDatePickerStyleInline A style indicating that the date pickers displays as an inline, editable field. UIDatePickerStyleWheels A style indicating that the date picker displays as a wheel picker.
But when using
setPreferredDatePickerStyle_(), 1 corresponds to Wheel, 2 corresponds to Compact, and 3 corresponds to Inline.
Some notes on the DatePicker styles (date only):
- Inline does work (and shows the calendar inline), but you can only set it from the main thread, otherwise you get an ObjC exception. It's much taller than the wheel, approximately 320x310.
- Compact is approximately 80x35 (but its width shrinks with shorter date strings). If you shrink it in the .pyui editor, the date won't be visible there, but it will still work when you run your app.
(also, thanks to cvp for the code to set the style!)
@bensaccount I think that the numeric value is the sequence order of the enumeration cases, starting from 0.
@cvp It's not always though. I posted a counterexample.
cvp last edited by
@bensaccount I Know and that is the first time I meet this change in the enum order. Weird
JonB last edited by
@bensaccount when looking at the apple docs, if you click on the name that you want, then switch the mode to Swift, it will usually show you the corresponding number.
There are also many places that have searchable iOS header files. If you find the header that has the enum you want, it will show the names in order.
NString constants can often be found using the in_dll method that was in dgelessus's post that cvp linked to.
switch the mode to Swift, it will usually show you the corresponding number.
I didn't know that, marvelous (as usual), thanks for the info
it will show the names in order.
Not true for UIDatePickerStyle, that's why it is weird...