views:

334

answers:

2

Hi,

I am trying to execute different things depending on what os the users iPhone is using.

Currently I have the below, which says - "if the device is 3.1, post this message"

    #ifdef __IPHONE_3_1
    NSLog(@"this device is 3.1");
    #endif

But, How can I get it to say - "If the device is 3.1 or higher, post this message" ?

Thank you very much.

A: 

Well this seems to do it.

    #if __IPHONE_OS_VERSION_MAX_REQUIRED >= __IPHONE_3_2
    NSLog(@"this device less than 3.2");
    #endif

I don't know why though because, to me, it reads - " if the OS version is greater than or equal to 3.2"
But, it returns - "if the iPhone OS is below 3.2"

Can anyone explain what this actually means?

Jonathan
Well __IPHONE_OS_VERSION_MAX_REQUIRED seems weird to me; maybe you should use __IPHONE_OS_VERSION_MIN_REQUIRED instead.
crimson_penguin
+2  A: 

See http://stackoverflow.com/questions/820142/how-to-target-a-specific-iphone-version

crimson_penguin
+1. It sounds like you want the app to work on versions lower than 3.1. Preprocessor macros don't do that; see the second half of the accepted answer there.
Chris Long
Yes, thank you both. Chris you were right. Macros were the wrong for what I wanted.
Jonathan