Getting the SDK version at compile time

Discussion in 'iOS Programming' started by JimBobBennett, May 10, 2009.

  1. JimBobBennett macrumors member

    May 4, 2009
    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?

  2. PhoneyDeveloper macrumors 68040


    Sep 2, 2008
    		cell.textLabel.textColor = [UIColor blackColor];
    		cell.textLabel.text = [mDataList objectAtIndex:indexPath.row];
    		cell.textColor = [UIColor blackColor];
    		cell.text = [mDataList objectAtIndex:indexPath.row];
    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.
  3. JimBobBennett thread starter macrumors member

    May 4, 2009

    Thats exactly what I was after, thank you very much!

Share This Page