I custom draw my TableView Cells by defining a macro #define DRAW_SET 1
Somewhere throughout the life cycle of the app I want to change the appearance of the cells, so I implemented an IBAction method that then #undef DRAW_SET the macro and defines it with a value of 2 #define DRAW_SET 2.
The issue that I am having is that the macro is not being undefined and/or redefined. Could this be due to public/private calls?
Thanks, Clinton
Macros are compiler instructions. After compilation, every macro is replaced with the corresponding value / statement.
#undeflets you undefine a macro, but again, as part of the compilation logic, not runtime logic.Typically macros are used for statically adding debug code during the development cycle, then removing it when you deploy your app (to keep the size down). For example:
Another place I have used macros is when targeting different operating systems:
These macros can be defined in various places – your compiler will give you a lot of them for free and you can set them as part of your build process.
But the key thing here is, they are not changeable at runtime.
What you probably want to do is define a variable somewhere, maybe on your application delegate as a property, which is fairly easy to access from anywhere in your app:
Then in your code look at the variable that’s been set: