As the iPad app I am making has been growing its size, it is hard for me to keep track of UI design values. Here, I am talking about values such as a table’s width, background colors, and a title’s font.
I would like to organize all UI design-related values and objects more efficiently.
How do you organize these?
- Do you #define values in a header file?
- Do you declare them as global variables or not?
- Do you put your values one static class?
- Or do you think not-organizing these values is rather better?
I would like to hear your advice.
Thank you 🙂
Yes it depends, therefore just some rules of thumb…
…in cases where I might want to change this locally only, eg for constants, colors, alignments, button images, … the main reason why I do this however is the documentation it allows by giving the local defines a long explaining name
…an all my apps I have a MainDataManager Class, that holds all the variables I need globally – for the UI part often I have my own globally used object. This is extremely useful, simplifies the code, and probably one of the most important things I learned early on. might also see here Using Variable of AppDelegate as a Global Variable – question regarding release/retain
…static classes exist kind of conceptually. Static variables are quite useful when you want to give a method some kind of memory of its own. However, none plays an important role in my UI.
In general, I like to use IB to layout the screens but set all the button names, labels, texts in the code. Why? Because when I have to localize the app maintaining multiple XIB files (for each language there will be one isolated XIB file to maintain) becomes a real burden even if there is only one single change in the layout.All the global constant settings are always kept in GloblDefinitions.h while at the same time I have in my .pch file this entry #import “GlobalDefinitions.h”
So the combintation of a delegate variable provided globally + GlobalDefinitions.h for constants is my solution.