Getting the SDK version at compile time

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

  1. JimBobBennett macrumors member

    Joined:
    May 4, 2009
    #1
    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!
     
  2. PhoneyDeveloper macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #2
    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.
     
  3. JimBobBennett thread starter macrumors member

    Joined:
    May 4, 2009
    #3

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

Share This Page