views:

243

answers:

3

Hi

Is there any way I can find out in my app if the user is running it on a device with OS 2.x or 3.0?

I tried adding a tag like the iPhone project templates do, but it doesn't seem to work.

#ifndef __IPHONE_3_0
//MY CODE FOR 3.0 GOES HERE
#else
//2.x CODE HERE
#endif

Thanks.

+3  A: 

Check out [[UIDevice currentDevice] systemVersion]. This will contain the version string.

Diederik Hoogenboom
+1  A: 

Depending on what you are trying to do, it is better to test for functionality rather than a specific version.

g .
+2  A: 
#ifndef __IPHONE_3_0
#define __IPHONE_3_0 30000
#endif
#if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_3_0
    [[startButton titleLabel] setFont:playFont];
#else
    [startButton setFont:playFont];
#endif
Saurabh