Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

JimBobBennett

macrumors member
Original poster
May 4, 2009
65
0
I'm currently wading my way through my first app, and I decided to build it with SDK 3.0 to see if there was any issues.
It turns out a few table things are deprecated and there are new ways of doing it (using the new initWithStyle on UITableViewCell, not initWithFrame, etc).
How can I code so that if its built with 2.2.1, the old way is used, whereas if it built with 3.0 the new way is used? Are there any SDK version #defines, or is there a standard way to do it?

Thanks!
 
Code:
#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 30000
		cell.textLabel.textColor = [UIColor blackColor];
		cell.textLabel.text = [mDataList objectAtIndex:indexPath.row];
#else
		cell.textColor = [UIColor blackColor];
		cell.text = [mDataList objectAtIndex:indexPath.row];
#endif

Note that this lets you compile two different versions without warnings. If you want a single codebase that builds for 2.x and uses 3.0 features it's more complicated.
 
Code:
#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 30000
		cell.textLabel.textColor = [UIColor blackColor];
		cell.textLabel.text = [mDataList objectAtIndex:indexPath.row];
#else
		cell.textColor = [UIColor blackColor];
		cell.text = [mDataList objectAtIndex:indexPath.row];
#endif

Note that this lets you compile two different versions without warnings. If you want a single codebase that builds for 2.x and uses 3.0 features it's more complicated.


Thats exactly what I was after, thank you very much!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.