Highly useful Objective-C code
I just got the inspiration to add the following line of code to the app delegate header of my latest iPhone application:
#define VERY_YES YES |
If you are wondering about the etymology of this, please check out the following informational message:
Where does the term “very yes” originate from?
I leave it to the imagination and creativity of my fellow developers to adapt this code to run in other flavors of C. Please make sure to credit me if you decide to use it.
I’m not sure about this, could I see some example usages?
Sure, let’s say you had an application with a preferences dialog, and on the preferences dialog there was a UISwitch (with corresponding IBOutlet) with a label next to it that said “I am cool”, you might have code in your viewDidLoad that looks like this:
if ([userName isEqualToString:@”BP”])
{
[coolnessSwitch setOn:VERY_YES];
}
You’re welcome.
I think there may be some error in your logic, below is the corrected code.
#define HELLS_NO !VERY_YES
if ([userName isEqualToString:@”BP”])
{
// by definition !VERY_YES == HELLS_NO
[coolnessSwitch setOn:!VERY_YES];
}