I have an objective-c class method, which for a given launch of the application will always return the same value; I remember reading somewhere that I could declare a function in such a way that the compiler would understand this and make appropriate optimisations.
(It may have had something to do with the static
keyword, but I can't remember, and Google only tells me "they're not static methods, they're class methods", which isn't what I'm talking about at all.)
My specific situation—though the question applies to any function or method—is a category on UIColor
, which returns application-specific colour values in a similar way to [UIColor redColor]
et. al. While these colours may be customised per device and may change from one run to the next, they will always be the same value for each run of the application.
While I'm also interested in whether there's particular value in any such optimisations, I'm far more interested in the actual declaration. I'm happy to hear if I'm "doing it wrong," but I'd also like to hear how I can actually declare a function or method in this manner.
UPDATE: It has nothing to do with static
; sorry, that was irrelevant.