I came across the following code and am wondering what the #statement means and if there are any good places to learn how to use the syntax:
#if __IPHONE_3_0
cell.textLabel.text = [photoTitles objectAtIndex:indexPath.row];
cell.textLabel.font = [UIFont systemFontOfSize:13.0];
#else
cell.text = [photoTitles objectAtIndex:indexPath.row];
cell.font = [UIFont systemFontOfSize:13.0];
#endif
This isn’t Objective-C, it’s the “C preprocessor”, which is basically a specialized text parsing system that is run on every source file in your project before it’s actually compiled. It’s the same system that processes the
#importdirectives.Think of it as providing “meta” compiling for your code. In this case, there’s a compiler environment variable for iPhone 3.0. If that variable is present, the first two lines of code get compiled. If not, the second two do.
Much more info is here: http://en.wikipedia.org/wiki/C_preprocessor