Why is it that this code works?
// in a constants file:
#define ADFadeOutSpeed 1.1
// then, later, in another file:
-(void)fadeOut:(UIView *)sender{
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:ADFadeOutSpeed];
sender.alpha = 0.0;
[UIView commitAnimations];
}
I was expecting that the compiler would complain that ADFadeOutSpeed was not strongly typed.
Because #define doesn’t create a variable or object, it’s a compiler command that says ‘replace all instances of foo with bar’ — so what’s happening, quit eliterally, is that ADFadeOutSpeed is read as 1.1 every time it shows in your code. The compiler doesn’t see:
it sees